Custom text for each product in confirmation email repeats

Highlighted
New Member
2 0 0

Hey all - hoping someone can help me with this custom code issue as Shopify support wasn't able to help. I have custom code in my order confirmation email for each product in my store, so that custom text is shown based on which products are in the customers order. 

CODE EXAMPLE: 

{% if line.product.type == 'Provisions' %}
CUSTOM TEXT PARAGRAPH<br><br>
CUSTOM TEXT PARAGRAPH<br><br>
{% endif %}

The problem I'm having is - if someone purchases more than one product from this Provisions type (lets say 1 almonds and 1 granola), the message displays twice in the customer email. Is there any way in liquid to limit this? Or another workaround? Any ideas welcome! 

0 Likes
Highlighted
New Member
2 0 0

Oh, I just found a general liquid code for limiting the loop! 

Here's the full code incase anyone else encounters this issue. Thanks @spicydesign for this answer on another thread! 

{% for item in cart.items %}
    {% if item.product.type == 'Product Type' %}
        {% if forloop.first %}
            //message goes here
        {% endif %}
    {% endif %}
{% endfor %}

 

0 Likes