0
On the Woocommerce site that I am developing, I will be selling not only to the end customer, but also to resellers. The problem is that dealers are exempt from TAX and therefore need a custom function to activate the zero tax rate for certain type of user.
Therefore, my problem is that the code I have works perfectly (when the user is an administrator or reseller), but I do not know how to make these changes to reflect only one product category (wine).
Here’s the code I’m using:
function wc_diff_rate_for_user( $tax_class, $product ) {
$current_user = wp_get_current_user();
$current_user_data = get_userdata($current_user->ID);
if ( in_array( 'administrator', $current_user_data->roles ) || in_array( 'reseller', $current_user_data->roles ) )
$tax_class = 'Zero Rate';
return $tax_class;
}
add_filter( 'woocommerce_product_get_tax_class', 'wc_diff_rate_for_user', 10, 2 );
add_filter( 'woocommerce_product_variation_get_tax_class', 'wc_diff_rate_for_user', 10, 2 );
How can I make this work only in one product category?