I figured out how to do this, from reading a whole lot of Stack Exchange posts about a variety of related topics, and trying a whole bunch of things that didn’t work, so I thought I’d post my code here since it does seem to work correctly.
First thing is to set up a tax in the Standard Rates part of the Woocommerce Tax tab. Make a row with the country code “GB” (Great Britain) with a tax rate of 20%. If you did nothing else, then this would collect the 20% VAT on all shipments to GB.
Now, you need code that’s going to zero-out the tax rate if the cart subtotal is >= 135£.
I followed WooCommerce’s recommendation and installed the Code Snippets plugin. Once you do that, then you need to create a new snippet with the code below; set it to “Only run in front end” from the radio buttons beneath the editor window. Save it with a useful name, and add some comments explaining what the point of this is, to make life better for your future self.
Note that the code below differs in significant ways from what is on the Woocommerce website (here and here, which — annoyingly and astoundingly — do not work, and their stated modification of “change 110 to 135” is simplistic, has the wrong comparison operator, and doesn’t account for currency exchange between the US & UK — that is, if your store works in US$).
I hope other people find this helpful for the Brexit VAT 135£ zero rate problem, and that you don’t have to waste an entire afternoon figuring this out from scratch. CAVEAT: I’m not a PHP expert, and probably can’t answer anyone’s questions; I’m really good at modifying other people’s code and cobbling together other people’s solutions, but that’s about where my expertise ends. I’m sharing this because it seems to work and I’m frankly pissed that Woocommerce’s official solution is pathetic.
function apply_uk_zero_tax_rate( $cart ) {
//UK VAT limit is 135 GBP; as of 2/11/2021, that's $186.25
$VAT_limit_UK = 186.25;
// get customer shipping location
$customer_country = WC()->customer->get_shipping_country();
// Loop through cart items to get cart subtotal
foreach ( $cart->get_cart() as $cart_item ) {
$subtotal += $cart_item['line_total'];
}
// Now check: If country <> GB (Great Britain), OR
// country = GB & cart subtotal less than 135£, THEN
// do nothing & keep standard tax rates
if ( ($customer_country != 'GB') || ( ($customer_country == 'GB') && ($subtotal < $VAT_limit_UK) ) )
return;
// Otherwise, loop through cart & set each item's tax rate to zero rate
// (Note use of slug 'zero-rate', instead of name 'Zero rate')
foreach ( $cart->get_cart() as $cart_item ) {
$cart_item['data']->set_tax_class( 'zero-rate' );
}
}
add_filter( 'woocommerce_before_calculate_totals', 'apply_uk_zero_tax_rate', 10, 1 );