<p>Answer is yes, you could use an adjuster to try and make the price "even" while in the cart.</p>

CC BY-SA 3.0
2017-07-11T04:59:23.060Z
2017-07-11T04:59:23.060Z
Luke Holder
<p>I put together an example adjuster that checks for a shipping address in Switzerland or the EU, and then applies the 8% or 19% adjustment to the order's item subtotal. It does not include shipping in the tax amount.</p>

<p>You would still need to register this via a plugin, <a href="https://craftcms.stackexchange.com/questions/19754/getting-started-with-order-adjuster-plugin">see this thread for an example</a>.</p>

<pre><code>    &lt;?php

    namespace Commerce\Adjusters;

    use Craft\Commerce_OrderAdjustmentModel;
    use Craft\Commerce_OrderModel;

    class MyAdjuster implements Commerce_AdjusterInterface {

      public function adjust(Commerce_OrderModel &amp;$order, array $lineItems = []){

        $euCountries = array(
        'AT', 'BE', 'HR', 'BG', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IE',
        'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'GB'
        );

        if($order-&gt;shippingMethodHandle !== NULL &amp;&amp; sizeof($order-&gt;lineItems) &gt; 0)
        {

          $countryCode = $order-&gt;shippingAddress-&gt;getCountry()-&gt;iso;

          if(in_array($countryCode, $euCountries))
          {
            // Country is in EU
            $salesTax = $order-&gt;itemSubtotal * 0.19;
          }
          else if ( $countryCode == "CH" )
          {
            // Country is Switzerland
            $salesTax = $order-&gt;itemSubtotal * 0.08;
          }
          else
          {
            return [];
          }

          $order-&gt;baseTax = $order-&gt;baseTax + $salesTax;

          $taxAdjuster = new Commerce_OrderAdjustmentModel();

          $taxAdjuster-&gt;type = "Tax";
          $taxAdjuster-&gt;name = "Sales Tax";
          $taxAdjuster-&gt;description = "Adds "+$salesTax+" of tax to the order";
          $taxAdjuster-&gt;amount = +$salesTax;
          $taxAdjuster-&gt;orderId = $order-&gt;id;
          // If your Adjuster affects lineItems rather than the total, you record the ids here
          $taxAdjuster-&gt;optionsJson = [ 'lineItemsAffected' =&gt; null ];
          $taxAdjuster-&gt;included = false;

          return [$taxAdjuster];
        } else {
          return [];
        };
      }
    }
</code></pre>

CC BY-SA 3.0
2017-08-01T18:34:47.010Z
2017-08-01T18:34:47.010Z
Rob Knecht
<p>I have a question about adjusters: I am working on a shop which has two tax zones (Switzerland and EU) and two tax rates (8% and 19%). The tax should always be included in the item price. From my understanding that is not possible for both tax zones at the same time. So I am having my eye on the adjusters.</p>

<p>I would use an adjuster to do the following: 
The client facing cart on the front end gets no adjustments. Only after the shipping address has been confirmed I would apply either one or the other adjustment (8% or 19% included) conditionally via the plugin to the order.</p>

<p>Does that make sense? Is that possible and if so is this even the best way to go or am I missing something which is more awesome?</p>

<p>If the answer is <strong><em>yes</em></strong> then I would invest more time and just dig into it.</p>

<p>Thanks in advance!</p>

<plugin-craftcommerce><adjusters>
Adjusters: Conditionally include tax in price
# Adjusters: Conditionally include tax in price

(Asked by: username_0 on 2017-04-18)

I have a question about adjusters: I am working on a shop which has two tax zones (Switzerland and EU) and two tax rates (8% and 19%). The tax should always be included in the item price. From my understanding that is not possible for both tax zones at the same time. So I am having my eye on the adjusters.

I would use an adjuster to do the following:
The client facing cart on the front end gets no adjustments. Only after the shipping address has been confirmed I would apply either one or the other adjustment (8% or 19% included) conditionally via the plugin to the order.

Does that make sense? Is that possible and if so is this even the best way to go or am I missing something which is more awesome?

If the answer is ***yes*** then I would invest more time and just dig into it.

Thanks in advance!

**Tags:** plugin-craftcommerce, adjusters


---

## 2 answers

### Answer by username_1 on 2017-07-11. Score: 2

Answer is yes, you could use an adjuster to try and make the price "even" while in the cart.


---

### Answer by username_2 on 2017-08-01. Score: 1

I put together an example adjuster that checks for a shipping address in Switzerland or the EU, and then applies the 8% or 19% adjustment to the order's item subtotal. It does not include shipping in the tax amount.
You would still need to register this via a plugin, see this thread for an example.
    shippingMethodHandle !== NULL && sizeof($order->lineItems) > 0)
        {

          $countryCode = $order->shippingAddress->getCountry()->iso;

          if(in_array($countryCode, $euCountries))
          {
            // Country is in EU
            $salesTax = $order->itemSubtotal * 0.19;
          }
          else if ( $countryCode == "CH" )
          {
            // Country is Switzerland
            $salesTax = $order->itemSubtotal * 0.08;
          }
          else
          {
            return [];
          }

          $order->baseTax = $order->baseTax + $salesTax;

          $taxAdjuster = new Commerce_OrderAdjustmentModel();

          $taxAdjuster->type = "Tax";
          $taxAdjuster->name = "Sales Tax";
          $taxAdjuster->description = "Adds "+$salesTax+" of tax to the order";
          $taxAdjuster->amount = +$salesTax;
          $taxAdjuster->orderId = $order->id;
          // If your Adjuster affects lineItems rather than the total, you record the ids here
          $taxAdjuster->optionsJson = [ 'lineItemsAffected' => null ];
          $taxAdjuster->included = false;

          return [$taxAdjuster];
        } else {
          return [];
        };
      }
    }


---

