Confirmation email liquid customization

New Member
2 0 7

I am working on sending 2 different emails based on whether an order is custom or not. I got most of the code to work, but the {% else %} email text is duplicated and I can't figure out why. Here's the code I'm using & I'm attaching am image of the preview email with duplicated text. 


{% capture email_title %}Thank you for your purchase! {% endcapture %}
{% capture email_body %}
  {% for line in line_items %}
{% if line.title contains "Custom" %}
Hi {{ customer.first_name }}, Thanks so much for your custom order. <a href=""> To submit your photos and additional information please fill out this form. </a> When your order is ready to be shipped you will receive another email with tracking information. 
{% else %}
  Hi {{ customer.first_name }}, Thanks so much for your order. You will get another notification when your order is ready to be shipped.
{% endif %}
{% endfor %}
      {% if delivery_instructions != blank  %}
        <p><b>Delivery information:</b> {{ delivery_instructions }}</p>     
{% endif %}
{% endcapture %}


Reply 1 (1)
161 34 56

I think it's because you're doing this inside a for loop, which will output for as many items that are in the cart, probably 2 in the preview.

Developer of Liquify Chrome Extension -- Enhance the Shopify Theme Code Editor

Theme Developer -- Drop me a line