Skip to content

Instantly share code, notes, and snippets.

@mikejolley
Created September 9, 2013 09:58
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 mikejolley/6493682 to your computer and use it in GitHub Desktop.
Save mikejolley/6493682 to your computer and use it in GitHub Desktop.
WooCommerce - Show zero rated tax lines when except
add_filter( 'woocommerce_cart_tax_totals', 'show_zero_rate_taxes' );
function show_zero_rate_taxes( $tax_totals ) {
global $woocommerce;
if ( empty( $tax_totals ) && $woocommerce->customer->is_vat_exempt() ) {
$tax_totals['zero-rated'] = (object) array(
'label' => 'Zero Rated Tax',
'amount' => 0,
'formatted_amount' => woocommerce_price( 0 ),
'name' => 'Zero Rated Tax',
'is_compound' => false
);
}
return $tax_totals;
}
@fcarlini
Copy link

Hey Mike,

I'm looking for a way to have it that the Zero Rate tax takes place when a subtotal is 999.99 or more. I need it to work this way due to MD state law. Any suggestions?

@hannahswain
Copy link

hannahswain commented May 17, 2018

If you don't want to do the check for is_vat_exempt(), for example if you're working with a 0% VAT, then change line 6 to look like this:
if ( empty( $tax_totals ) ) {

Note that the zero rate tax line will then always show up at checkout if taxes are 0. Tested on WooCommerce 3.3.5

@beayeric
Copy link

Awesome thanks for the code.
This is not working for me. Any idea?
Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment