2017-05-31 47 views
0

我正在嘗試添加一個過濾器以吸引商務,該計算基於購物車數量計算稅額,並且僅當物品運送至紐約時,訂單> 110 $不付稅,並且訂單< 110運到紐約州的$ &應支付8,865%的稅。 我發現這個代碼的地方,但不知道如果作品,既不在哪裏使用它。添加Woo商業稅過濾器

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 any help!

回答

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

加在可溼性粉劑內容/插件/ woocommerce /包括/類-WC-cart.php