Tax Exempt Role
-
Hi,
I am using your plugin which works great. Now I created a new user role called: “Dealer” and I am trying to tax exempt all users which have the dealer role.
I am using the code found below and have already inserted my Dealer role and placed code in functions.php : https://gist.github.com/kloon/5948116
// Place the following code in your theme’s functions.php file and replace tax_exempt_role with the name of the role to apply to
add_action( ‘init’, ‘woocommerce_customer_tax_exempt’ );
function woocommerce_customer_tax_exempt() {
global $woocommerce;
if ( is_user_logged_in() ) {
$tax_exempt = current_user_can( ‘dealer’);
$woocommerce->customer->set_is_vat_exempt( $tax_exempt );
}
}I tried multiple times, unfortunately, tax still remains.
Next, I also created a Zero Tax rate in WooCommerce and tried this code:/* No tax for dealer */
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);// <== <== <== <== <== <== <== Here you put your user role slug
if ( in_array( ‘dealer’, $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 );This didn’t work either. I am not sure why this isn’t working. Could someone look at the codes above or maybe even paste a different snippet here which may work.
- The topic ‘Tax Exempt Role’ is closed to new replies.