WooCommerce产品附加产品与其产品使用相同的TAX / VAT。我需要为附加组件设置条件不同的TAX / VAT。
发布中继为_product_addons
。我玩过cart_item_key
,但是几天后我仍然无法突破...如何有条件地(排除一些)设置不同的(与其产品) WooCommerce产品附加产品的税/增值税?
谢谢
function add_cart_item_data( $cart_item_key, $product_id, $variation_id ) {
$taxable = get_post_meta( $product_id, '_tax_status', true );
$taxclass = 'standard';
$cart_item_key['tax_status'] = $taxable;
$cart_item_key['tax_class'] = $taxclass;
return $cart_item_key;
}
add_filter( 'woocommerce_add_cart_item_data', 'add_cart_item_data', 10, 3 );
输出:
Array
(
[addons] => Array
(
[0] => Array
(
[name] => Smuteční stuha s nápisem
[value] => test
[price] => 150
[field_name] => 268-smutecni-stuha-s-napisem-0
[field_type] => custom_text
[price_type] => quantity_based
)
)
[tax_status] => taxable
[tax_class] => standard