Question

This is the code I thought would work but it doesn't:

{% for discount in discounts %}
   {% if discount.code == 'testcoupon123' %} 
      You will get a free item!
   {% endif %}
{% endfor %}

Can anyone please explain what is wrong with this?

Was it helpful?

Solution

I know from using email template codes the discount code field can be multiple discount code(s) for an order, see this document for the brief explanation:

http://docs.shopify.com/manual/settings/notifications/email-variables#discounts

Have you tried using: {% if discount.first.code == 'testcoupon123' %}

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top