<p>I suspect there is a much better way, but I use something like this, looping over all cart adjustments, checking the type of adjustment.</p>
<p>We use the <code>adjustment.sourceSnapshot</code> for the coupon code, otherwise access the attributes on the adjustment directly, which is a <code>Discount</code> model.</p>
<pre><code>        {% for adjustment in cart.adjustments if adjustment.type == &quot;discount&quot; %}
            {% set isCoupon = adjustment.sourceSnapshot.code ??? false %}              
            {% if isCoupon %}
                Coupon: {{ adjustment.sourceSnapshot.code }}
            {% else %}
                {{ adjustment.name }}&lt;br /&gt;
                {{ adjustment.description }}
            {% endif %}

         {% endfor %}
</code></pre>
<p>...that works.</p>
<p>Documentation, such as it is, is here:
<a href="https://craftcms.com/docs/commerce/3.x/adjusters.html#adjusting" rel="nofollow noreferrer">https://craftcms.com/docs/commerce/3.x/adjusters.html#adjusting</a></p>
<p>And the available attributes for a discount model:
<a href="https://docs.craftcms.com/commerce/api/v3/craft-commerce-models-discount.html#app" rel="nofollow noreferrer">https://docs.craftcms.com/commerce/api/v3/craft-commerce-models-discount.html#app</a></p>
<p>(or src: <a href="https://github.com/craftcms/commerce/blob/master/src/models/Discount.php" rel="nofollow noreferrer">https://github.com/craftcms/commerce/blob/master/src/models/Discount.php</a>)</p>
<p>(Honestly, though, even looking at the documentation now, it's really not obvious how to come to this code....)</p>

CC BY-SA 4.0
2020-11-15T22:26:17.837Z
Thanks for sharing your method!
Piotr Pogorzelski
CC BY-SA 4.0
2020-11-15T21:24:00.020Z
2020-11-16T02:15:42.003Z
2020-11-16T02:15:42.003Z
Jeremy Daalder
<p>We can retrieve description of discount applied to cart that has its own coupon like this:</p>
<pre><code>craft.commerce.discounts.getDiscountByCode(cart.couponCode).description
</code></pre>
<p>Is it possible for discount that do not have coupons and are applied automatically?</p>

<plugin-craftcommerce>
Commerce - show description of discount without coupon applied to cart
# Commerce - show description of discount without coupon applied to cart

(Asked by: username_0 on 2020-11-14)

We can retrieve description of discount applied to cart that has its own coupon like this:
craft.commerce.discounts.getDiscountByCode(cart.couponCode).description

Is it possible for discount that do not have coupons and are applied automatically?

**Tags:** plugin-craftcommerce


---

## 1 answers

### Answer by username_1 on 2020-11-15. Score: 2 | Accepted answer

I suspect there is a much better way, but I use something like this, looping over all cart adjustments, checking the type of adjustment.
We use the adjustment.sourceSnapshot for the coupon code, otherwise access the attributes on the adjustment directly, which is a Discount model.
        {% for adjustment in cart.adjustments if adjustment.type == "discount" %}
            {% set isCoupon = adjustment.sourceSnapshot.code ??? false %}              
            {% if isCoupon %}
                Coupon: {{ adjustment.sourceSnapshot.code }}
            {% else %}
                {{ adjustment.name }}
                {{ adjustment.description }}
            {% endif %}

         {% endfor %}

...that works.
Documentation, such as it is, is here:
https://craftcms.com/docs/commerce/3.x/adjusters.html#adjusting
And the available attributes for a discount model:
https://docs.craftcms.com/commerce/api/v3/craft-commerce-models-discount.html#app
(or src: https://github.com/craftcms/commerce/blob/master/src/models/Discount.php)
(Honestly, though, even looking at the documentation now, it's really not obvious how to come to this code....)

> **Comments:**
> **username_0**: Thanks for sharing your method!  

---

