添加Woo Commerce税务过滤器

时间:2017-05-31 14:56:18

标签: php woocommerce hook-woocommerce

我正在尝试添加一个过滤器来吸引商业,根据购物车的数量来计算税额,并且仅当物品运到纽约时,订单> 110 $不纳税,订单< 110 $&运往纽约州应缴纳8,865%的税。 我发现这个代码在某个地方,但不确定是否有效,无论在哪里使用它。

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

Apreciatte任何帮助!

1 个答案:

答案 0 :(得分:0)

        // Added the contion for Tax below/above the 110
        $this->total = max( 0, apply_filters( 'woocommerce_calculated_total', round( $this->cart_contents_total +  $this->fee_total, $this->dp ), $this ) );

        if($this->total > 110){
            $this->total = max( 0, apply_filters( 'woocommerce_calculated_total', round( $this->cart_contents_total + $this->tax_total + $this->shipping_tax_total + $this->shipping_total + $this->fee_total, $this->dp ), $this ) );
        }else{
            $this->taxes  = 0;
        }

在wp-content / plugins / woocommerce / includes / class-wc-cart.php中添加

相关问题