Wordpress - Woocommerce: Hook to apply Tax to Shipping price?

3k views Asked by At

Using Woocommerce plugin.

I get this code to add Tax based in the buyer rol.

It works fine but the Tax is only applied to product price. I also need to apply the same Tax to the Shipping cost.

I guess I need to use another filter parameter but I don't know which one.

Here is the real code:

function wc_re_eq( $tax_class, $product ) {  
 if ( is_user_logged_in() && current_user_can( 'client_re' ) ) {  
  $tax_class = 'R.E';  
 }  
 return $tax_class;  
}  
add_filter( 'woocommerce_product_tax_class', 'wc_re_eq', 1, 2 ); 
2

There are 2 answers

1
Aibrean On BEST ANSWER

You should be applying that in your tax rate chart. There is a checkbox for shipping, where you apply tax to shipping.

WooCommerce documentation: https://docs.woocommerce.com/document/setting-up-taxes-in-woocommerce/#tax-rate-examples

0
BiliWeiss On

@Jpash do you solve it?

Through the label "R.E.", I get the feeling that your problem is related to "recargo de equivalencia" of Spain.

I have the same problem. For certain users I must apply another type of tax only for the shipping costs.