Skip to content

Instantly share code, notes, and snippets.

@bentasm1
Forked from kloon/functions.php
Last active January 20, 2022 22:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bentasm1/afda4441fcf19f2c8c57 to your computer and use it in GitHub Desktop.
Save bentasm1/afda4441fcf19f2c8c57 to your computer and use it in GitHub Desktop.
Set WooCommerce Tax Exemption based on user role
<?php
add_filter( 'init', 'wc_tax_exempt_user_roles' );
function wc_tax_exempt_user_roles() {
if ( ! is_admin() ) {
global $woocommerce;
if ( current_user_can('wholesaler') || current_user_can('distributor') ) {
$woocommerce->customer->set_is_vat_exempt(true);
} else {
$woocommerce->customer->set_is_vat_exempt(false);
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment