Created
July 8, 2013 11:52
-
-
Save kloon/5948116 to your computer and use it in GitHub Desktop.
WooCommerce Customer Tax Exempt based on 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 | |
// Place the following code in your theme's functions.php file and replace tax_exempt_role with the name of the role to apply to | |
add_action( 'init', 'woocommerce_customer_tax_exempt' ); | |
function woocommerce_customer_tax_exempt() { | |
global $woocommerce; | |
if ( is_user_logged_in() ) { | |
$tax_exempt = current_user_can( 'tax_exempt_role'); | |
$woocommerce->customer->set_is_vat_exempt( $tax_exempt ); | |
} | |
} |
This broke my site when I made it a snippet. Do I just need to create the role first?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is great.
What do I do for multiple roles?
Also this seems to have worked on the front-end but creates a strange error when I try to go back to the admin area. I get this: http://i.imgur.com/nNHMSAZ.png