<p>What have you tried so far?</p>

<p>The <a href="https://craftcommerce.com/docs/discounts" rel="nofollow">documentation</a> seems to be missing, but looking at <code>/craft/plugins/commerce/models/Commerce_DiscountModel.php</code> you can find the properties <code>purchaseQty</code> and <code>perItemDiscount</code> that you need for the calculations.</p>

<pre><code>{% for prod in product.variants %}
   {% for discount in craft.commerce.discounts %}
      {% set totalPrice = (discount.purchaseQty * prod.price) %}
      {% set totalDiscountPrice = (discount.purchaseQty * (prod.price + discount.perItemDiscount)) %}
      {% set totalDiscount = (totalPrice-totalDiscountPrice) %}
      {% set totalDiscountPercent = (totalDiscount/totalPrice)*100 %}

      &lt;p&gt;If you buy {{ discount.purchaseQty }} items, you only pay {{ totalDiscountPrice|currency(cart.currency) }} instead of {{ prod.price|currency(cart.currency) }} per item. So your total today is only {{ totalDiscountPrice|currency(cart.currency) }} insted of {{ totalPrice|currency(cart.currency) }}. You therefore save {{ totalDiscount|currency(cart.currency) }}. That's a discount of {{ totalDiscountPercent|round }}%.&lt;/p&gt;
   {% endfor %}
{% endfor %}
</code></pre>

<p>This will show all of the discounts for all of the products. You will need to modify it slightly if you have specified the discount for a specific product. You also need to check if the discount is enabled or not using <code>discount.enabled</code></p>

CC BY-SA 3.0
2016-05-31T13:13:49.717Z
Hi Alex, it works great! I have added this: `{% set discountPricePerItem = (prod.price + discount.perItemDiscount) %}` to be able to display the "per item"-price on each discount level. Many thanks.
Patrick
CC BY-SA 3.0
2017-03-30T10:54:35.723Z
Hi Alex, I have specific discount rules for each product separately. How can I modify this code so it would show ONLY the product specific discounts and NOT all the discounts?
Patrick
CC BY-SA 3.0
2017-03-30T10:56:47.610Z
Also, `{% if discount.enabled == true %}` doesn't work. Do I need to write this differently?
Patrick
CC BY-SA 3.0
2017-03-30T10:56:56.590Z
Can you please open it as a new question so that I can give you a proper answer rather than just in a comment?
Alexander Holsgrove
CC BY-SA 3.0
2017-03-30T11:11:27.423Z
I used this to filter product specific discounts: `{% if product.id in discount.productIds or product.typeId in discount.productTypeIds %}` – and it works
Patrick
CC BY-SA 3.0
2016-05-31T12:06:45.437Z
2016-05-31T12:06:45.437Z
Alexander Holsgrove
<h2>starting point</h2>

<p>I have the following offer with quantity discounts for a series of my products:</p>

<ul>
<li>Buy 1 item and get $5 off per item</li>
<li>Buy 2 items and get $10 off per item</li>
<li>Buy 3 items and get $15 off per item</li>
</ul>

<p>I set these <strong>discount rules</strong> in my control panel under "commerce" > "promotions".</p>

<hr>

<h2>product template</h2>

<p>Now in my product template, I would like to be able to output (for each quantity level):</p>

<ol>
<li>the normal (non-discounted) price</li>
<li>the discounted price</li>
<li>savings in terms of $</li>
<li>savings in terms of %</li>
</ol>

<hr>

<h2>example</h2>

<p>For example it would then say on the product page (output):</p>

<blockquote>
  <p>"If you buy 2 items, you only pay $[<em>discount price for 2 items</em>]
  instead of $[<em>normal price</em>] per item. So your total today is only
  $[<em>2 x discount price for 2 items</em>] insted of $[<em>2 x normal price</em>].
  You therefore save $[(2 x normal price)-(2 x discount price for 2
  items)]. That's a discount of […]%."</p>
</blockquote>

<p>The same goes for the discount offer of ordering 1 item or 3 items.</p>

<hr>

<p><strong>How can I accomplish this with all the discounts and math operations involved?</strong></p>

<plugin-craftcommerce><promotions>
Commerce: Show quantity discounts
# Commerce: Show quantity discounts

(Asked by: username_0 on 2016-05-31)

## starting point

I have the following offer with quantity discounts for a series of my products:

* Buy 1 item and get $5 off per item
* Buy 2 items and get $10 off per item
* Buy 3 items and get $15 off per item

I set these **discount rules** in my control panel under "commerce" > "promotions".

---

## product template

Now in my product template, I would like to be able to output (for each quantity level):

1. the normal (non-discounted) price
2. the discounted price
3. savings in terms of $
4. savings in terms of %

---

## example

For example it would then say on the product page (output):

> "If you buy 2 items, you only pay $[*discount price for 2 items*]
> instead of $[*normal price*] per item. So your total today is only
> $[*2 x discount price for 2 items*] insted of $[*2 x normal price*].
> You therefore save $[(2 x normal price)-(2 x discount price for 2
> items)]. That's a discount of […]%."

The same goes for the discount offer of ordering 1 item or 3 items.

---

**How can I accomplish this with all the discounts and math operations involved?**

**Tags:** plugin-craftcommerce, promotions


---

## 1 answers

### Answer by username_1 on 2016-05-31. Score: 3 | Accepted answer

What have you tried so far?
The documentation seems to be missing, but looking at /craft/plugins/commerce/models/Commerce_DiscountModel.php you can find the properties purchaseQty and perItemDiscount that you need for the calculations.
{% for prod in product.variants %}
   {% for discount in craft.commerce.discounts %}
      {% set totalPrice = (discount.purchaseQty * prod.price) %}
      {% set totalDiscountPrice = (discount.purchaseQty * (prod.price + discount.perItemDiscount)) %}
      {% set totalDiscount = (totalPrice-totalDiscountPrice) %}
      {% set totalDiscountPercent = (totalDiscount/totalPrice)*100 %}

      If you buy {{ discount.purchaseQty }} items, you only pay {{ totalDiscountPrice|currency(cart.currency) }} instead of {{ prod.price|currency(cart.currency) }} per item. So your total today is only {{ totalDiscountPrice|currency(cart.currency) }} insted of {{ totalPrice|currency(cart.currency) }}. You therefore save {{ totalDiscount|currency(cart.currency) }}. That's a discount of {{ totalDiscountPercent|round }}%.
   {% endfor %}
{% endfor %}

This will show all of the discounts for all of the products. You will need to modify it slightly if you have specified the discount for a specific product. You also need to check if the discount is enabled or not using discount.enabled

> **Comments:**
> **username_0**: Hi Alex, it works great! I have added this: `{% set discountPricePerItem = (prod.price + discount.perItemDiscount) %}` to be able to display the "per item"-price on each discount level. Many thanks.  
> **username_0**: Hi Alex, I have specific discount rules for each product separately. How can I modify this code so it would show ONLY the product specific discounts and NOT all the discounts?  
> **username_0**: Also, `{% if discount.enabled == true %}` doesn't work. Do I need to write this differently?  
> **username_1**: Can you please open it as a new question so that I can give you a proper answer rather than just in a comment?  
> **username_0**: I used this to filter product specific discounts: `{% if product.id in discount.productIds or product.typeId in discount.productTypeIds %}` – and it works  

---

