<p>I had the same issue, turns out I had Craft Commerce Lite installed when the feature requires the Pro version.</p>

CC BY-SA 4.0
2020-09-25T09:31:57.270Z
2020-09-25T09:31:57.270Z
Jayden Smith
<p>Have you made sure the module has bootstrapped? Check the app config and uncomment the bootstrap line</p>

CC BY-SA 4.0
2019-08-06T20:40:33.443Z
2019-08-06T20:40:33.443Z
Dean Sanderson
<p>Following <a href="https://docs.craftcms.com/commerce/v2/adjusters.html" rel="nofollow noreferrer">https://docs.craftcms.com/commerce/v2/adjusters.html</a> I am unable to register an adjuster in my module.</p>

<p>in my Module.php file I have placed the following inside init() alongside other stuff being registered (that are working)</p>

<pre><code>use craft\events\RegisterComponentTypesEvent;
use craft\commerce\services\OrderAdjustments;
use modules\mymodule\adjusters\DiscountAdjuster;

Event::on(OrderAdjustments::class, 
    OrderAdjustments::EVENT_REGISTER_ORDER_ADJUSTERS, function(RegisterComponentTypesEvent $event) {
    $event-&gt;types[] = DiscountAdjuster::class;
});
</code></pre>

<p>And in src/adjusters/DiscountAdjuster.php I have</p>

<pre><code>namespace modules\mymodule\adjusters;

use Craft;
use craft\base\Component;
use craft\commerce\base\AdjusterInterface;
use craft\commerce\elements\Order;
use craft\commerce\models\OrderAdjustment;

class DiscountAdjuster extends Component implements AdjusterInterface
{

    public function adjust(Order $order): array
    {
        $adjustments = [];

        foreach ($order-&gt;getLineItems() as $item) {
            $adjustment = new OrderAdjustment;
            $adjustment-&gt;type = 'discount';
            $adjustment-&gt;name = '$2 off';
            $adjustment-&gt;description = '$2 off everything in the store';
            $adjustment-&gt;sourceSnapshot = [ 'data' =&gt; 'value']; // This can contain information about how the adjustment came to be
            $adjustment-&gt;amount = -2;
            $adjustment-&gt;setOrder($order);
            $adjustment-&gt;setLineItem($item);

            $adjustments[] = $adjustment;
        }

        return $adjustments;
    }
}
</code></pre>

<p>This should take 2 off of every line item when I add items to the cart, no? Nothing happens though. And if i put something like <code>die()</code> in <code>public function adjust</code>, that isn't registered either.</p>

<p>What am I missing?</p>

<p>I also tried adapting this example: <a href="https://craftcms.stackexchange.com/questions/28184/demo-repo-for-an-adjuster-module-for-commerce-2">Demo repo for an Adjuster module for Commerce 2?</a> However I'm faced with the same issue.</p>

CC BY-SA 4.0
2019-08-07T10:27:40.683Z
Can you log something or `Craft::dd()` in your event listener?
Luke Holder
CC BY-SA 4.0
2019-08-07T16:55:10.240Z
I am almost curtain the module has not been bootstrapped. I had the same issue but have a Yii background and found the issue pretty quick.
Dean Sanderson
<plugin-development><craft3><plugin-craftcommerce2><modules>
Unable to register adjuster in module
# Unable to register adjuster in module

(Asked by: username_0 on 2019-02-24)

Following https://docs.craftcms.com/commerce/v2/adjusters.html I am unable to register an adjuster in my module.
in my Module.php file I have placed the following inside init() alongside other stuff being registered (that are working)
use craft\events\RegisterComponentTypesEvent;
use craft\commerce\services\OrderAdjustments;
use modules\mymodule\adjusters\DiscountAdjuster;

Event::on(OrderAdjustments::class, 
    OrderAdjustments::EVENT_REGISTER_ORDER_ADJUSTERS, function(RegisterComponentTypesEvent $event) {
    $event->types[] = DiscountAdjuster::class;
});

And in src/adjusters/DiscountAdjuster.php I have
namespace modules\mymodule\adjusters;

use Craft;
use craft\base\Component;
use craft\commerce\base\AdjusterInterface;
use craft\commerce\elements\Order;
use craft\commerce\models\OrderAdjustment;

class DiscountAdjuster extends Component implements AdjusterInterface
{

    public function adjust(Order $order): array
    {
        $adjustments = [];

        foreach ($order->getLineItems() as $item) {
            $adjustment = new OrderAdjustment;
            $adjustment->type = 'discount';
            $adjustment->name = '$2 off';
            $adjustment->description = '$2 off everything in the store';
            $adjustment->sourceSnapshot = [ 'data' => 'value']; // This can contain information about how the adjustment came to be
            $adjustment->amount = -2;
            $adjustment->setOrder($order);
            $adjustment->setLineItem($item);

            $adjustments[] = $adjustment;
        }

        return $adjustments;
    }
}

This should take 2 off of every line item when I add items to the cart, no? Nothing happens though. And if i put something like die() in public function adjust, that isn't registered either.
What am I missing?
I also tried adapting this example: Demo repo for an Adjuster module for Commerce 2? However I'm faced with the same issue.

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

> **Comments:**
> **username_1**: Can you log something or `Craft::dd()` in your event listener?  
> **username_2**: I am almost curtain the module has not been bootstrapped. I had the same issue but have a Yii background and found the issue pretty quick.  

---

## 2 answers

### Answer by username_3 on 2020-09-25. Score: 2 | Accepted answer

I had the same issue, turns out I had Craft Commerce Lite installed when the feature requires the Pro version.


---

### Answer by username_2 on 2019-08-06. Score: 1

Have you made sure the module has bootstrapped? Check the app config and uncomment the bootstrap line


---

