Created
August 28, 2017 09:42
-
-
Save vovadocent/3c7c57fed3e5eba90fa8eb080638fd11 to your computer and use it in GitHub Desktop.
Woocommerce Apply Different Tax Class Rate 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 | |
function specialWholesaleTaxClass( $tax_class, $product ) { | |
global $current_user; | |
if (in_array('wholesale_customer', $current_user->roles)) | |
$tax_class = 'Special Wholesale'; | |
else | |
$tax_class = 'Zero Rate'; | |
return $tax_class; | |
} | |
add_filter( 'woocommerce_product_get_tax_class', 'specialWholesaleTaxClass', 1, 2 ); | |
add_filter( 'woocommerce_product_variation_get_tax_class', 'specialWholesaleTaxClass', 1, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment