mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-29 11:32:21 +08:00
https://stackoverflow.com/questions/77836800/disable-tax-calculation-for-customer-user-role-in-woocommerce
11 lines
416 B
Text
11 lines
416 B
Text
add_action( 'template_redirect', 'set_customer_user_role_vat_exempt' );
|
|
function set_customer_user_role_vat_exempt(){
|
|
global $current_user;
|
|
if ( ! is_user_logged_in() )
|
|
return;
|
|
|
|
// Set "customer" user role "Vat exempt" if is not set yet
|
|
if ( in_array( 'customer', $current_user->roles ) && ! WC()->customer->is_vat_exempt() ) {
|
|
WC()->customer->set_is_vat_exempt( true );
|
|
}
|
|
}
|