<p>You currently can not know if a product matches a discount until it is added to the cart and the discount engine does the checks based on the full conditions of the discount. Many conditions of which are directly related to the product being in the cart. For example a minimum order qty.</p>

<p>But if you want to return a possible list of discounts to show the custom of which the product MAY be eligible before adding to the cart then you can do something like this:</p>

<pre><code>{% for discount in craft.commerce.discounts %}
  Possible Discounts:&lt;br&gt;
  {% if product.id in discount.productIds or product.typeId in discount.productTypeIds %}
    {{discount.description}}&lt;br&gt;
  {% endif%}
{% endfor %}
</code></pre>

<p>This only checks the product and it's product type is explicitly listed in the discount, but you can add additional conditions if you wished.</p>

<p>It is recommended the discount description has a readable sentance for how this discount could be applied. For example:</p>

<blockquote>
  <p>Buy 2 or more sneakers and get 75% off.</p>
</blockquote>

CC BY-SA 3.0
2016-07-06T07:37:13.503Z
You should correct the OR operator from `||` to `or`
Amit Erandole
CC BY-SA 3.0
2016-07-06T05:26:52.103Z
2016-07-06T15:25:01.957Z
2016-07-06T15:25:01.957Z
Luke Holder
<p>How do I show possible discounts available to the current product?</p>

<plugin-craftcommerce>
How can I know the discounts available to a product before adding it to the cart?
# How can I know the discounts available to a product before adding it to the cart?

(Asked by: username_0 on 2016-07-06)

How do I show possible discounts available to the current product?

**Tags:** plugin-craftcommerce

---

## 1 answers

### Answer by username_0 on 2016-07-06. Score: 2

You currently can not know if a product matches a discount until it is added to the cart and the discount engine does the checks based on the full conditions of the discount. Many conditions of which are directly related to the product being in the cart. For example a minimum order qty.
But if you want to return a possible list of discounts to show the custom of which the product MAY be eligible before adding to the cart then you can do something like this:
{% for discount in craft.commerce.discounts %}
  Possible Discounts:
  {% if product.id in discount.productIds or product.typeId in discount.productTypeIds %}
    {{discount.description}}
  {% endif%}
{% endfor %}

This only checks the product and it's product type is explicitly listed in the discount, but you can add additional conditions if you wished.
It is recommended the discount description has a readable sentance for how this discount could be applied. For example:

Buy 2 or more sneakers and get 75% off.

> **Comments:**
> **username_1**: You should correct the OR operator from `||` to `or`  

---

