Answers.Body: <p>I've created a stub/reference Adjuster module, <a href="https://github.com/oof-bar/commerce-example-adjuster" rel="nofollow noreferrer">here</a>.</p>
  
  <p>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.</p>
  
  <p>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.</p>
  
  <p>You can replace the two calls to <code>$adjustment-&gt;amount = $myAmount;</code> with anything you like—including Craft API calls that fetch values off of Elements, get plugin or environment settings, inspect <code>LineItem</code> options, etc.</p>
  
  <p>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 <code>Adjustment</code>, it doesn't matter how you derive it. ✌️</p>
  
  <p><em>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.</em></p>
  
  <blockquote>
    <p>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.</p>
  </blockquote>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-24T06:42:01.423Z
Answers.Text: Wow thank you August! Will be testing this today : )
Answers.UserDisplayName: James Greig
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2018-10-23T23:10:28.520Z
Answers.LastActivityDate: 2018-10-23T23:10:28.520Z
Answers.UserDisplayName: August Miller
Body: <p>Would it be possible for someone to create a demo of a barebones Adjuster module, similar to <a href="https://github.com/cliveportman/craftcommerce-adjuster" rel="nofollow noreferrer">https://github.com/cliveportman/craftcommerce-adjuster</a> but for Commerce 2?</p>
  
  <p>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.</p>
  
Tags: <plugin-craftcommerce2><modules>
Title: Demo repo for an Adjuster module for Commerce 2?
ThreadText: # Demo repo for an Adjuster module for Commerce 2?
  
  (Asked by: username_0 on 2018-10-23)
  
  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.
  
  **Tags:** plugin-craftcommerce2, modules
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2018-10-23. Score: 3 | Accepted answer
  
  I've created a stub/reference Adjuster module, [here](https://github.com/oof-bar/commerce-example-adjuster).
  
  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: username_0 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.
  
  > **Comments:**
  > **username_0**: Wow thank you username_1! Will be testing this today : )  
  
  ---
  
  