首页 文章

添加Woo Commerce税务过滤器

提问于
浏览
0

我正在尝试添加一个过滤器以吸引商业,根据购物车的数量计算税额,只有当物品运到纽约时,订单> 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
    // 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中添加

相关问题