Last active
October 4, 2022 10:40
-
-
Save woogist/48c776c39df23d53df8d to your computer and use it in GitHub Desktop.
Apply different tax rates based on user role
This file contains 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 | |
/** | |
* Apply a different tax rate based on the user role. | |
*/ | |
function wc_diff_rate_for_user( $tax_class, $product ) { | |
if ( is_user_logged_in() && current_user_can( 'administrator' ) ) { | |
$tax_class = 'Zero Rate'; | |
} | |
return $tax_class; | |
} | |
add_filter( 'woocommerce_product_get_tax_class', 'wc_diff_rate_for_user', 1, 2 ); | |
add_filter( 'woocommerce_product_variation_get_tax_class', 'wc_diff_rate_for_user', 1, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hello
I used this code and worked great for simple products. For variable products i still see prices with VAT.
Please advise