Answers.Body: <p>You need to add the <a href="https://craftcms.com/docs/commerce/4.x/extend/adjusters.html#writing-an-adjuster" rel="nofollow noreferrer">adjuster</a> to your logic via a module/plugin:</p>
  <p>And the main body of your adjuster should look like this (if I correctly read your logic):</p>
  <pre><code>&lt;?php
  
  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 CustomAdjuster extends Component implements AdjusterInterface
  {
      /**
       * @param Order $order
       *
       * @return array|OrderAdjustment[]
       */
      public function adjust(Order $order): array
      {
          $adjustments = [];
  
          $lineItems = $order-&gt;getLineItems();
  
          foreach ($lineItems as $i =&gt; $item) {
              // First product? Skip it
              if (0 === $i) {
                  continue;
              }
              
              $adjustment = new OrderAdjustment();
              $adjustment-&gt;type = 'discount';
              $adjustment-&gt;name = &quot;My 50$ discount&quot;;
              $adjustment-&gt;description = &quot;My 50$ discount&quot;;
              // `sourceSnapshot` can contain information to explain the adjustment
              $adjustment-&gt;sourceSnapshot = [ 'data' =&gt; 'value' ];
              $adjustment-&gt;amount = 50;
              $adjustment-&gt;setOrder($order);
              $adjustment-&gt;setLineItem($item);
              $adjustments[] = $adjustment;
          }
  
          return $adjustments;
      }
  }
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-02-16T19:56:15.277Z
Answers.Text: That will discount everything in my cart after the first item, but I need it to only apply to a certain product variant.
  
  The logic needs to be along the lines of if product id = 50, and quantity is > 1, then apply the discount to everything after the first.
Answers.UserDisplayName: artmem
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-01-12T20:35:31.737Z
Answers.LastActivityDate: 2023-01-12T20:35:31.737Z
Answers.UserDisplayName: RomanAvr
Body: <p>I have a product where I want to charge the full price ($300) for the first one, and then a discounted amount ($50) for each additional one.</p>
  <p>So if a customer orders one, the cost is $300. Two would be $350. Three would be $400, etc.</p>
  <p>I know I can set a discount that applies to all items, but is there a way to only apply it after the first?</p>
  
Tags: <plugin-craftcommerce3><discounts>
Title: Commerce 3: Apply discount only to additional items
ThreadText: # Commerce 3: Apply discount only to additional items
  
  (Asked by: username_0 on 2023-01-11)
  
  I have a product where I want to charge the full price ($300) for the first one, and then a discounted amount ($50) for each additional one.
  
  So if a customer orders one, the cost is $300. Two would be $350. Three would be $400, etc.
  
  I know I can set a discount that applies to all items, but is there a way to only apply it after the first?
  
  **Tags:** plugin-craftcommerce3, discounts
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-01-12. Score: 1
  
  You need to add the [adjuster](https://craftcms.com/docs/commerce/4.x/extend/adjusters.html#writing-an-adjuster) to your logic via a module/plugin:
  
  And the main body of your adjuster should look like this (if I correctly read your logic):
  
  ```
  <?php
  
  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 CustomAdjuster extends Component implements AdjusterInterface
  {
      /**
       * @param Order $order
       *
       * @return array|OrderAdjustment[]
       */
      public function adjust(Order $order): array
      {
          $adjustments = [];
  
          $lineItems = $order->getLineItems();
  
          foreach ($lineItems as $i => $item) {
              // First product? Skip it
              if (0 === $i) {
                  continue;
              }
              
              $adjustment = new OrderAdjustment();
              $adjustment->type = 'discount';
              $adjustment->name = "My 50$ discount";
              $adjustment->description = "My 50$ discount";
              // `sourceSnapshot` can contain information to explain the adjustment
              $adjustment->sourceSnapshot = [ 'data' => 'value' ];
              $adjustment->amount = 50;
              $adjustment->setOrder($order);
              $adjustment->setLineItem($item);
              $adjustments[] = $adjustment;
          }
  
          return $adjustments;
      }
  }
  
  ```
  
  > **Comments:**
  > **username_0**: That will discount everything in my cart after the first item, but I need it to only apply to a certain product variant.  The logic needs to be along the lines of if product id = 50, and quantity is > 1, then apply the discount to everything after the first.  
  
  ---
  
  