Skip to content

Instantly share code, notes, and snippets.

@kloon
Created July 8, 2013 11:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kloon/5948116 to your computer and use it in GitHub Desktop.
Save kloon/5948116 to your computer and use it in GitHub Desktop.
WooCommerce Customer Tax Exempt based on role
<?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 );
}
}
@ParadoxDesign
Copy link

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

@klishb
Copy link

klishb commented Jun 17, 2018

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