Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to Remove All Taxes in WooCommerce for a Minimum Cart Total and Specific Countries?

You can provide tax exemption to customers based on minimum cart total and specific countries with this code snippet. The tax exemption is based on the total cart subtotal being equal to or greater than $50 and the shipping country being India (IN).

add_action( 'woocommerce_calculate_totals', 'ts_set_customer_tax_exempt' );
function ts_set_customer_tax_exempt( $cart ) {
    if ( is_admin() && ! defined('DOING_AJAX') )
        return;

    $min_amount = 50; // Minimal cart amount
    $countries  = array('IN'); // Defined countries array

    $subtotal   = floatval( $cart->cart_contents_total );
    $shipping   = floatval( $cart->shipping_total );
    $fees       = floatval( $cart->fee_total );
    $total      = $subtotal + $shipping + $fees; // cart total (without taxes including shipping and fees)

    $country    = WC()->customer->get_shipping_country();
    $country    = empty($country) ? WC()->customer->get_billing_country() : $country;
    $vat_exempt = WC()->customer->is_vat_exempt();
    $condition  = in_array( $country, $countries ) && $total >= $min_amount;

    if ( $condition && ! $vat_exempt ) {
        WC()->customer->set_is_vat_exempt( true ); // Set customer tax exempt
    } elseif ( ! $condition && $vat_exempt ) {
        WC()->customer->set_is_vat_exempt( false ); // Remove customer tax exempt
    }
}

add_action( 'woocommerce_thankyou', 'ts_remove_customer_tax_exempt' );
function ts_remove_customer_tax_exempt( $order_id ) {
    if ( WC()->customer->is_vat_exempt() ) {
        WC()->customer->set_is_vat_exempt( false );
    }
}

Output

As the cart subtotal is greater than the minimum amount defined in the code, and the Shipping country being India, the Tax total is removed from the cart totals.

How to Remove All Taxes in WooCommerce for a Minimum Cart Total and Specific Countries?

If either the cart subtotal falls below the minimum amount stipulated in the code, or the shipping country is not set to India, the tax total remains included in the cart totals.

How to Remove All Taxes in WooCommerce for a Minimum Cart Total and Specific Countries?

A lot more customization can be done based on cart total like the above one. You can also set all shipping method cost to zero based on cart total in WooCommerce which will help customers to benefit from zero shipping cost.

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

Share It:

Subscribe
Notify of
0 Comments
Newest
Oldest
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x