Hide VAT in WooCommerce for specific user only on frontend

I use the following to hide VAT from non-professional users on the front end. My problem is that when an order is placed, the VAT remains zero, leading to incorrect calculations. Products are created with prices excluding VAT. For non-professional users, the product price should be the price excluding VAT plus VAT, resulting in the final price including VAT. However, I can't use 'excl' and 'incl' because I have a special display of prices at different stages: cart, checkout, and order. Is there a way to hide VAT only on the front end for specific users? function zero_rate_for_custom_user_role( $tax_class, $product ) { if ( is_user_logged_in() ) { $current_user = wp_get_current_user(); $is_pro_user = 'yes' == get_user_meta( $current_user->ID, 'professionnel', true ); if ( !$is_pro_user ) { $tax_class = 'zero-rate'; } }else{ $tax_class = 'zero-rate'; } return $tax_class; } add_filter('woocommerce_product_get_tax_class','zero_rate_for_custom_user_role', 10, 2 ); add_filter( 'woocommerce_product_variation_get_tax_class', 'zero_rate_for_custom_user_role', 10, 2 );

Comment (0)

You’ll be in good company