woocommerce:在产品增值税中添加运输增值税,而不是单独的值

问题描述

我创建了一个使用add_rate函数提供运输选项的运输插件:

Text

然后在woocommerce中进行以下设置:

Text

Text

Text

(由于我正在使用add_rate方法,因此没有其他运输设置)

问题是当我这样做时,我得到以下结果:

Text

第二条“ VAT”行是运输的行,我理想地说谎是将这两个值作为单个值。我想念什么?任何帮助将不胜感激。

编辑:运输代码:

function foo_shipping_method() {

    if ( ! class_exists( 'WC_NinjaShip_Shipping_Method' ) ) {

        class WC_FooShip_Shipping_Method extends WC_Shipping_Method {

            /**
             * constructor for your shipping class
             *
             * @access public
             * @return void
             */
            public function __construct($instance_id = 0) {

                $this->id = 'foo_shipping_method';
                $this->method_title = __( 'FooBar Shipping' );
                $this->method_description = __( 'Shipping method for FooBar' );

                $this->init();

                // needs to be after $this->init();
                $this->enabled = isset( $this->settings['enabled'] ) ? $this->settings['enabled'] : 'yes';

            }


            /**
             * init your settings
             *
             * @access public
             * @return void
             */
            function init() {

                // load the settings api
                $this->init_form_fields();
                $this->init_settings();

                // save settings in admin if you have any defined
                add_action( 'woocommerce_update_options_shipping_' . $this->id,array( $this,'process_admin_options' ) );

            }


            /**
             * define settings field for this shipping
             *
             * @return void
             */
            function init_form_fields() {

                $this->form_fields = array(

                    'enabled' => array(
                        'title' => __( 'Enable','foo_shipping_method' ),'type' => 'checkbox','description' => __( 'Enable this shipping.','default' => 'yes'
                    ),);

            }


            /**
             * calculate_shipping function.
             *
             * @access public
             * @param mixed $package
             * @return void
             */
            public function calculate_shipping( $package = array() ) {

                global $woocommerce,$wpdb,$nf;

                // get cart total
                $cart_total = $woocommerce->cart->get_cart_total();
                $cart_total = str_replace(',','',str_replace('R',strip_tags($cart_total)));

                $rate1 = array(
                    'id' => 'foo_shipping_method_delivery_jhb','label' => 'Delivery: Foo Bar','cost' => array('97.39'),'taxes' => array('SHIP VAT' => '14.61'),//14.61
                    'calc_tax' => 'per_order'
                );
                $this->add_rate( $rate1 );

            }
        }
    }
}
add_action( 'woocommerce_shipping_init','foo_shipping_method' );

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...