首页 > 解决方案 > 基于小计金额的 Woocommerce 税

问题描述

我需要根据小计金额应用不同的税级而不是 WooCommerce 标准税级。如果小计金额小于特定值,则对购物车应用不同的税种。我已将以下代码应用于我的孩子theme's function.php。但这也行不通。任何帮助,将不胜感激。

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;
} 

标签: wordpresswoocommercehook-woocommerce

解决方案


推荐阅读