<p>Looking at the <code>\craft\commerce\services\OrderAdjustments</code> you should be able to change the ordering of your adjustments by using the <code>\craft\commerce\services\OrderAdjustments::EVENT_REGISTER_ORDER_ADJUSTERS</code> event.</p>

<pre class="lang-php prettyprint-override"><code>use craft\events\RegisterComponentTypesEvent;
use craft\commerce\services\OrderAdjustments;
use yii\base\Event;

Event::on(
    OrderAdjustments::class,
    OrderAdjustments::EVENT_REGISTER_ORDER_ADJUSTERS,
    function (RegisterComponentTypesEvent $e) {
        $e-&gt;types = [
            // Add the adjusters in whatever order you want here. Leaving this empty would disable all adjusters.
        ];
    }
);
</code></pre>

CC BY-SA 4.0
2019-03-05T21:16:35.523Z
So I'm using the Verbb Gift Voucher plugin in conjunction with my custom one. You're saying when I register my Adjuster, it should look something like:
`$event->types = [
                
                GiftVoucherAdjuster::class, CartAdjustmentsAdjuster::class
            ];`
Marc Miller
CC BY-SA 4.0
2019-03-06T03:11:09.190Z
Actually, I need the Gift Vouchers Adjuster to run before my CartAdjustementAdjuster. Doing this in my plugin, then disabling and enabling the 2 plugins again doesn't seem to work. Do I have to uninstall and install again? Then I'm back to square one and just easier to install in the correct order.
Marc Miller
CC BY-SA 4.0
2020-03-08T01:38:27.640Z
finally figured out that I had to add `use verbb\giftvoucher\adjusters\GiftVoucherAdjuster;` at the top of the file. Now I can use the code as @Maarten mentioned. It ends up looking like `$event->types = [
                    CartAdjustmentsAdjuster::class,
                    GiftVoucherAdjuster::class
                ];`
Marc Miller
CC BY-SA 4.0
2020-03-10T19:03:01.793Z
Thanks for sharing, Marc!
Maarten de Graaf
CC BY-SA 4.0
2019-03-04T19:08:30.490Z
2019-03-04T19:08:30.490Z
Maarten de Graaf
<p>In Craft Commerce 1, there is documentation on how to re-order adjustments that do similar things.
<a href="https://docs.craftcms.com/commerce/v1/adjusters.html#ordering-adjustments" rel="nofollow noreferrer">https://docs.craftcms.com/commerce/v1/adjusters.html#ordering-adjustments</a></p>

<p>But I don't see any similar documentation for how to do that in Commerce 2.</p>

<p>I have 2 plugins that make adjustments to the Sale price and then Order total, but if run in the wrong order, it doesn't work. </p>

<p>Simple solution is to uninstall the plugins and install them in the correct sequence, but was wondering if there was still a way to force them to run in a certain order.</p>

<plugin-development><plugin-craftcommerce2>
Order Adjusters in Commerce 2
# Order Adjusters in Commerce 2

(Asked by: username_0 on 2019-03-04)

In Craft Commerce 1, there is documentation on how to re-order adjustments that do similar things.
<https://docs.craftcms.com/commerce/v1/adjusters.html#ordering-adjustments>

But I don't see any similar documentation for how to do that in Commerce 2.

I have 2 plugins that make adjustments to the Sale price and then Order total, but if run in the wrong order, it doesn't work.

Simple solution is to uninstall the plugins and install them in the correct sequence, but was wondering if there was still a way to force them to run in a certain order.

**Tags:** plugin-development, plugin-craftcommerce2


---

## 1 answers

### Answer by username_1 on 2019-03-04. Score: 1 | Accepted answer

Looking at the \craft\commerce\services\OrderAdjustments you should be able to change the ordering of your adjustments by using the \craft\commerce\services\OrderAdjustments::EVENT_REGISTER_ORDER_ADJUSTERS event.
use craft\events\RegisterComponentTypesEvent;
use craft\commerce\services\OrderAdjustments;
use yii\base\Event;

Event::on(
    OrderAdjustments::class,
    OrderAdjustments::EVENT_REGISTER_ORDER_ADJUSTERS,
    function (RegisterComponentTypesEvent $e) {
        $e->types = [
            // Add the adjusters in whatever order you want here. Leaving this empty would disable all adjusters.
        ];
    }
);

> **Comments:**
> **username_0**: So I'm using the Verbb Gift Voucher plugin in conjunction with my custom one. You're saying when I register my Adjuster, it should look something like: `$event->types = [                                  GiftVoucherAdjuster::class, CartAdjustmentsAdjuster::class             ];`  
> **username_0**: Actually, I need the Gift Vouchers Adjuster to run before my CartAdjustementAdjuster. Doing this in my plugin, then disabling and enabling the 2 plugins again doesn't seem to work. Do I have to uninstall and install again? Then I'm back to square one and just easier to install in the correct order.  
> **username_0**: finally figured out that I had to add `use verbb\giftvoucher\adjusters\GiftVoucherAdjuster;` at the top of the file. Now I can use the code as @Maarten mentioned. It ends up looking like `$event->types = [                     CartAdjustmentsAdjuster::class,                     GiftVoucherAdjuster::class                 ];`  
> **username_1**: Thanks for sharing, Marc!  

---

