-
-
Save iamra/9586363b2de5c9ce1c170f290adb5eb8 to your computer and use it in GitHub Desktop.
WooCommerce set tax exemption based on user role
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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