Skip to content

Instantly share code, notes, and snippets.

@iMazed
Created January 12, 2021 13:47
Show Gist options
  • Save iMazed/a1373480a9a99933616e85bb95b13537 to your computer and use it in GitHub Desktop.
Save iMazed/a1373480a9a99933616e85bb95b13537 to your computer and use it in GitHub Desktop.
Brexit Tax Country Selector
add_filter( 'woocommerce_product_get_tax_class', 'big_apple_get_tax_class', 1, 2 );
function big_apple_get_tax_class( $tax_class, $product ) {
if ( WC()->cart->subtotal > 150 // 150 eur = 135 gbp, until a live rate is available
&& WC()->customer->get_billing_country() === 'GB' // only change the tax class for customers from GB. _billing_ can be changed to _shipping_ as well.
&& ! preg_match( 'BT', strtoupper( WC()->customer->get_billing_postcode() ) ) // but only those outside of Northern Ireland
) {
$tax_class = 'Zero Rate';
}
return $tax_class;
}
@luci-us
Copy link

luci-us commented Jan 13, 2021

Hi iMazed!
I tried to implement the snippet, didn't manage to work it through... In our case (shop) VAT is implemented via shipping country, I've tried to just replace billing for shipping but can't see any changes at the checkout prices... any thoughts?

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