Would it be possible for someone to create a demo of a barebones Adjuster module, similar to https://github.com/cliveportman/craftcommerce-adjuster but for Commerce 2?

I'm trying to follow the docs but can't piece everything together.... basically just looking for the most basic module possible for something that adjust the prices of an item in the cart.

1 Answer 1


I've created a stub/reference Adjuster module, here.

This demonstrates how to register two Adjusters via a custom module—one that creates a 5% discount on each line item, and one that creates a 10% discount on the entire order.

These adjusters have their logic hard-coded, which is to say: in order to modify the behavior/value of the adjustments, you have to change PHP files. Part of the benefit of Craft's built-in adjusters (Taxes, Discounts) is that they base their calculations on input from the merchant/admin, in the control panel.

You can replace the two calls to $adjustment->amount = $myAmount; with anything you like—including Craft API calls that fetch values off of Elements, get plugin or environment settings, inspect LineItem options, etc.

This is where Adjusters become immensely powerful. As long as you can provide a positive or negative value, a label, and a description for your Adjustment, it doesn't matter how you derive it. ✌️

This module is not meant to be installed as a plugin, or used as a submodule—it's probably best to just lift the code out and replace the generic classes and namespaces.

A bit of context: James and I spoke in Slack earlier today, which prompted the creation of this repo. The code has been adapted from private projects, but is now available under the MIT license.

  • Wow thank you August! Will be testing this today : ) Oct 24, 2018 at 6:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.