如何解决woocommerce:在产品增值税中添加运输增值税,而不是单独的值
我创建了一个使用add_rate函数提供运输选项的运输插件:
然后在woocommerce中进行以下设置:
(由于我正在使用add_rate方法,因此没有其他运输设置)
问题是当我这样做时,我得到以下结果:
第二条“ 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 举报,一经查实,本站将立刻删除。