Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 130709

Different tax rates based on the customer role not working for Variable Products

$
0
0

Replies: 0

After WC 3.0 update my condition to apply different tax rates based on a customer role is not working for Variable products.

I took that customization from your official documentation: https://docs.woocommerce.com/document/setting-up-taxes-in-woocommerce/#section-19

Now the filter used: woocommerce_product_tax_class i think it deprecated in favor of woocommerce_product_get_tax_class.

Even with this, these filter triggers for example in cart when a product is single, but when a variable product is in cart, it display tax, as the filter doesn’t trigger.

STEPS TO REPRODUCE THE ISSUE

1- Have 2 products, 1 single, 1 variable. Create Tax for an state, let’s say florida.

2- User this code customization in functions.php: https://docs.woocommerce.com/document/setting-up-taxes-in-woocommerce/#section-19

3- Add single product to cart, see there is no tax being calculated.

4- Add Variable Product to Cart, see there is tax being calculated.

5- Add Both, see that there is tax being calculated only for Variable Product.

Another easy way to test, is an echo on the filter:

function wc_diff_rate_for_user( $tax_class, $product ) {
if ( is_user_logged_in() && current_user_can( “administrator” ) ) {
$tax_class = “Zero Rate”;
}

echo “TAX IS DIFFERENT FOR ADMIN”;

return $tax_class;
}
add_filter( “woocommerce_product_tax_class”, “wc_diff_rate_for_user”, 1, 2 );

You will see that the echo displays only for the single product, not the variable product. An in like the Variable Product doesn’t trigger this filter.


Viewing all articles
Browse latest Browse all 130709

Trending Articles