I have applied “Zero rate” tax class for wholesale customer in shop page and cart page by following code-

function zero_rate_for_custom_user_role( $tax_class, $product ) {
// Getting the current user 
$current_user = wp_get_current_user();
$current_user_data = get_userdata($current_user->ID);

if ( in_array( 'wholesale_customer', $current_user_data->roles ) )
    $tax_class = 'Zero Rate';

return $tax_class;
add_filter( 'woocommerce_product_tax_class', 'zero_rate_for_custom_user_role', 1, 2 );

Its working fine for simple product but for variable product minimum and maximum prices still showing inclusive tax prices.

Please, give me solution how can I exclude the tax or applied “Zero rate” for variable product too.

For reference I have tried this solution but didn’t worked.

function woocommerce_variation_prices_hash($price_hash, $product, $display) {
if ( $display ) 
    $price_hash[] = $product->get_tax_class();
return $price_hash;
add_filter( 'woocommerce_get_variation_prices_hash', 'woocommerce_variation_prices_hash', 10, 3 );

Read more here: WooCommerce – Enabling "Zero rate" tax class to some specific user roles not working for Variable product


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: