Answers.Body: <p>As far as the release notes from Commerce 1.2:
  <a href="https://craftcommerce.com/changelog#build1323" rel="nofollow">https://craftcommerce.com/changelog#build1323</a></p>
  
  <p>It can only be given a minimum quantity of items now.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-12T12:27:52.503Z
Answers.Text: If i look into your question, i would create a discount coupon -> Conditions -> Add Products select Product A -> Minimum Purchase Quantity and Maximum Purchase Quantity set to 3 that would solve it.
  
  If it works please upvote it.
Answers.UserDisplayName: Bram B
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-10-12T08:13:36.517Z
Answers.LastActivityDate: 2016-10-12T08:13:36.517Z
Answers.UserDisplayName: Bram B
Answers.Body: <p>You can achieve this with a custom adjuster. Please refer the code snippet below.</p>
  
  <p>Create a new adjuster and apply your logic here</p>
  
  <pre><code>// check each line item
  foreach($lineItems as $lineItem)
  {
  ....
  &lt;your business logic here
  ....
  $discount_total = &lt;amount&gt;;
  }
  
  $order-&gt;baseDiscount = $order-&gt;baseDiscount - $discount_total;
  
  $myAdjuster-&gt;type = "Custom discount";
  $myAdjuster-&gt;name = "Group discount";
  $myAdjuster-&gt;description = "Total of discount";
  $myAdjuster-&gt;amount = -$discount_total;
  $myAdjuster-&gt;orderId = $order-&gt;id;
  //        //if your Adjuster affects lineItems rather than the total, you record the ids here
  $myAdjuster-&gt;optionsJson = ['lineItemsAffected'=&gt; null ];
  $myAdjuster-&gt;included = false;
  
  return [$myAdjuster];
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-09-08T14:05:17.113Z
Answers.LastActivityDate: 2017-09-08T14:05:17.113Z
Answers.UserDisplayName: Dasun Rathnayake
Body: <p>I know that I can apply a discount if a specific number of products is ordered. I could also add a discount for a specific product, with a specific amount. But, am I able to create a discount with this conditions:</p>
  
  <ul>
  <li>Applies to entire product type</li>
  <li>A specific number of <strong>one product</strong> is added to the cart</li>
  </ul>
  
  <p>So, if I set this discount for 3 products, but people buy 2 x PRODUCT A, 1 x PRODUCT B, it would not apply. If customers buy 3 x PRODUCT A, 2 x PRODUCT B, it would apply for product A.</p>
  
  <p>I could probably fix it with a plugin, but is it possible out of the box? Am I missing something?</p>
  
Tags: <plugin-craftcommerce><discounts>
Title: In Commerce, can I apply a discount only on a specific number of one product?
ThreadText: # In Commerce, can I apply a discount only on a specific number of one product?
  
  (Asked by: username_0 on 2016-10-12)
  
  I know that I can apply a discount if a specific number of products is ordered. I could also add a discount for a specific product, with a specific amount. But, am I able to create a discount with this conditions:
  
  * Applies to entire product type
  * A specific number of **one product** is added to the cart
  
  So, if I set this discount for 3 products, but people buy 2 x PRODUCT A, 1 x PRODUCT B, it would not apply. If customers buy 3 x PRODUCT A, 2 x PRODUCT B, it would apply for product A.
  
  I could probably fix it with a plugin, but is it possible out of the box? Am I missing something?
  
  **Tags:** plugin-craftcommerce, discounts
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2016-10-12. Score: 1 | Accepted answer
  
  As far as the release notes from Commerce 1.2:
  <https://craftcommerce.com/changelog#build1323>
  
  It can only be given a minimum quantity of items now.
  
  > **Comments:**
  > **username_1**: If i look into your question, i would create a discount coupon -> Conditions -> Add Products select Product A -> Minimum Purchase Quantity and Maximum Purchase Quantity set to 3 that would solve it.  If it works please upvote it.  
  
  ---
  
  ### Answer by username_2 on 2017-09-08. Score: 1
  
  You can achieve this with a custom adjuster. Please refer the code snippet below.
  
  Create a new adjuster and apply your logic here
  
  ```
  // check each line item
  foreach($lineItems as $lineItem)
  {
  ....
  <your business logic here
  ....
  $discount_total = <amount>;
  }
  
  $order->baseDiscount = $order->baseDiscount - $discount_total;
  
  $myAdjuster->type = "Custom discount";
  $myAdjuster->name = "Group discount";
  $myAdjuster->description = "Total of discount";
  $myAdjuster->amount = -$discount_total;
  $myAdjuster->orderId = $order->id;
  //        //if your Adjuster affects lineItems rather than the total, you record the ids here
  $myAdjuster->optionsJson = ['lineItemsAffected'=> null ];
  $myAdjuster->included = false;
  
  return [$myAdjuster];
  
  ```
  
  
  ---
  
  