# Remove all taxes in WooCommerce for a min cart total and specific countries

**URL:** <https://community.mainwp.com/t/remove-all-taxes-in-woocommerce-for-a-min-cart-total-and-specific-countries/2862>\
**Category:** Code Snippets\
**Tags:** wordpress, woocommerce\
**Created:** [March 12, 2021, 10:22pm UTC](https://community.mainwp.com/t/remove-all-taxes-in-woocommerce-for-a-min-cart-total-and-specific-countries/2862 "2021-03-12T22:22:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebastian-moran](https://community.mainwp.com/user_avatar/community.mainwp.com/sebastian-moran/32/16_2.png) [@sebastian-moran](https://community.mainwp.com/u/sebastian-moran)\
**Post date:** [March 12, 2021, 10:22pm UTC](https://community.mainwp.com/t/remove-all-taxes-in-woocommerce-for-a-min-cart-total-and-specific-countries/2862/1 "2021-03-12T22:22:14Z")

</div>

Remove all taxes in WooCommerce for a min cart total and specific countries in WooCommerce on your child site.

**Snippet Type**

`Execute on Child Sites`

**Snippet**

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

    $min_amount = 150; // Minimal cart amount
    $countries = array('GB'); // 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', 'remove_customer_tax_exempt' );
function remove_customer_tax_exempt( $order_id ) {
    if ( WC()->customer->is_vat_exempt() ) {
        WC()->customer->set_is_vat_exempt( false );
    }
}

```

---

<div class="post-metadata">

**Author:** ![system](https://community.mainwp.com/uploads/default/original/2X/4/4cfc87ac67e4ebdbfa0bbf0b19c8657f35a29a5b.png) [@system](https://community.mainwp.com/u/system)\
**Post date:** [April 11, 2021, 10:22pm UTC](https://community.mainwp.com/t/remove-all-taxes-in-woocommerce-for-a-min-cart-total-and-specific-countries/2862/2 "2021-04-11T22:22:48Z")

</div>

Closed on April 11, 2021, 10:22pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
