Answers.Body: <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>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-05T21:16:35.523Z
Answers.Text: 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
              ];`
Answers.UserDisplayName: Marc Miller
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-06T03:11:09.190Z
Answers.Text: 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.
Answers.UserDisplayName: Marc Miller
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-08T01:38:27.640Z
Answers.Text: 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
                  ];`
Answers.UserDisplayName: Marc Miller
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-03-10T19:03:01.793Z
Answers.Text: Thanks for sharing, Marc!
Answers.UserDisplayName: Maarten de Graaf
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-03-04T19:08:30.490Z
Answers.LastActivityDate: 2019-03-04T19:08:30.490Z
Answers.UserDisplayName: Maarten de Graaf
Body: <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>
  
Tags: <plugin-development><plugin-craftcommerce2>
Title: Order Adjusters in Commerce 2
ThreadText: # 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.
  
  ```php
  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 @username_1 mentioned. It ends up looking like `$event->types = [                     CartAdjustmentsAdjuster::class,                     GiftVoucherAdjuster::class                 ];`  
  > **username_1**: Thanks for sharing, username_0!  
  
  ---
  
  