1. Home
  2. Knowledge Base
  3. WooCommerce Fees and Discounts
  4. Exclude tax by user role
  1. Home
  2. Knowledge Base
  3. Advanced
  4. Exclude tax by user role
  1. Home
  2. Knowledge Base
  3. Role based pricing
  4. Exclude tax by user role

Exclude tax by user role

If you want to remove tax according to user role, you can use this snippet:

<?php
/**
* Remove tax for specific roles
*/
function prefix_exclude_tax_by_role() {
if( function_exists( 'WC' ) ) {
if( isset( WC()->customer ) ) {
$role = WC()->customer->get_role();
if( $role == 'administrator' ) {
WC()->customer->set_is_vat_exempt( true );
} else {
WC()->customer->set_is_vat_exempt( false );
}
}
}
}
add_action( 'wp', 'prefix_exclude_tax_by_role' );

Just update it with the role you wish to remove tax for.

You can see how to add this snippet here.

Was this article helpful?

Related Articles