I use WooCommerce and Members plugin. I have created special tax rate classes (CustomerTaxExemptTaxClass & CustomerPSTExemptTaxClass for customers who can be tax exempt or pay a certain tax only (pay only PST tax in Canada). I have created two new roles with the members plugin: Customer Tax Exempt & Customer PST Exempt.
I have added the following code into my Child Theme functions.php file, however it does not work.
/* APPLY DIFFERENT TAX RATE BASED ON CUSTOMER USER ROLE */
/* special tax rate: zero if role: Customer Tax Exempt */
function CustomerTaxExemptTaxClass( $tax_class, $product ) {
global $current_user;
if (is_user_logged_in() && current_user_can('customer_tax_exempt')) {
$tax_class = 'CustomerTaxExemptClass';
}
return $tax_class;
}
add_filter( 'woocommerce_product_tax_class', 'CustomerTaxExemptTaxClass', 1, 2 );
/* special tax rate: charge only GST if role: customer_pst_exempt */
function CustomerPSTExemptTaxClass( $tax_class, $product ) {
global $current_user;
if (is_user_logged_in() && current_user_can('customer_pst_exempt')) {
$tax_class = 'CustomerPSTExemptClass';
}
return $tax_class;
}
add_filter( 'woocommerce_product_tax_class', 'CustomerPSTExemptTaxClass', 1, 2 );
I used a suggested tax exempt code snippet, but I'm not PHP expert by any means.
Any help would be appreciated.
Thanks Lyse