我在这里使用的是官方文件:https://docs.woocommerce.com/document/setting-up-taxes-in-woocommerce 和下面的代码片段创建一个阈值触发器,这样低于110美元的订单就不会被征税。问题是,即使购物车中有项目,当此筛选器启动时,WC()->购物车->小计似乎始终为0。有什么想法/见解吗?
add_filter( \'woocommerce_product_tax_class\', \'big_apple_get_tax_class\', 1, 2 );
function big_apple_get_tax_class( $tax_class, $product ) {
if ( WC()->cart->subtotal <= 110 )
$tax_class = \'Zero Rate\';
return $tax_class;
}