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.
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.
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.