How can I charge different tax rates based on the shipping method a customer selects at checkout in Woocommerce? My store has one shipping option that lets international customers avoid the 7% VAT charged here in Thailand.
Here's how to disable taxes when Local Pickup is selected as the shipping option according to Woocommerce documentation:
add_filter( 'woocommerce_apply_base_tax_for_local_pickup', '__return_false' );
But how do I disable taxes on a custom shipping option?
Edit: I've started to work out a solution, but I could use some help with line 2. i.e. How to get the current shipping method?
function remove_tax_for_fob( $cart ) {
$ok_remove = get_shipping_method( 'FOB' );
if ($ok_remove){
$cart->remove_taxes();
}
return $cart;
}
add_action( 'woocommerce_calculate_totals', 'remove_tax_for_fob' );
calculate_shipping
method of your custom shipping option you can set'taxes' => false
. So before you set the rate check if the client is international, and then add the tax as required. – Anand ShahWC()->customer->is_vat_exempt = true
if the custom shipping option is selected will set the tax to 0 – Anand Shah