Created
January 12, 2021 13:47
-
-
Save iMazed/a1373480a9a99933616e85bb95b13537 to your computer and use it in GitHub Desktop.
Brexit Tax Country Selector
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
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?