Last active
October 20, 2022 10:35
-
-
Save opicron/a123dcfba6259410259a9481f5d65d9d to your computer and use it in GitHub Desktop.
Tax - exempt guests and customers #php #woocommerce
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 | |
/** | |
* Function that will check for user role and turn off VAT/tax for that role | |
*/ | |
function wc_diff_rate_for_user() { | |
// check for the user role | |
if ( ! is_user_logged_in() || current_user_can( 'customer' ) ) { | |
// set the customer object to have no VAT | |
WC()->customer->set_is_vat_exempt( true ); | |
} | |
} | |
add_action( 'template_redirect', 'wc_diff_rate_for_user', 1 ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment