There is a nice WooCommerce function you can use to exempt someone from Tax/VAT calculations. You could, for example, enable exemption once they enter a Tax/VAT number, or maybe if they specify a given ZIP code.

Such function is called set_is_vat_exempt(), and together with a little trick to “get” a checkout field on the go, the snippet is pretty simple to build and test. Enjoy!

WooCommerce: zero tax/vat if ZIP code equals ‘XYZ’

PHP Snippet: Remove Tax @ WooCommerce Checkout if Field Value Exists

/**
 * @snippet       Remove Tax if Field Value Exists - WooCommerce Checkout
 * @how-to        Get CustomizeWoo.com FREE
 * @sourcecode    https://businessbloomer.com/?p=21952
 * @author        Rodolfo Melogli
 * @compatible    WC 4.1
 */
 
add_action( 'woocommerce_checkout_update_order_review', 'bbloomer_taxexempt_checkout_based_on_zip' );
 
function bbloomer_taxexempt_checkout_based_on_zip( $post_data ) {
        WC()->customer->set_is_vat_exempt( false );
        parse_str( $post_data );
        if ( $billing_postcode === '32444' ) WC()->customer->set_is_vat_exempt( true );
}
Share:

Leave a Reply