Home » WooCommerce: Tax Exempt User Based on Checkout Field Value

WooCommerce: Tax Exempt User Based on Checkout Field Value

by Tutor Aspire

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 tutoraspire.com FREE
 * @author        Tutor Aspire, BusinessBloomer.com
 * @testedwith    WooCommerce 4.5
 * @donate $9     https://tutoraspire.com
 */
 
add_action( 'woocommerce_checkout_update_order_review', 'tutoraspire_taxexempt_checkout_based_on_zip' );
 
function tutoraspire_taxexempt_checkout_based_on_zip( $post_data ) {
        WC()->customer->set_is_vat_exempt( false );
        parse_str( $post_data, $output );
        if ( $output['billing_postcode'] === '32444' ) WC()->customer->set_is_vat_exempt( true );
}

You may also like