Cannot get if/else logic to work: e.g. if line item contain specific tag show information else do X

Windsinger
Tourist
19 0 1

Hello all and thanks in advance for any guidance.

I am setting up a "Recently Purchased" section based on a customer's previous orders.

The below code successfully  outputs the most recently purchased product along with some custom associated products based upon a product tag (works great)...

BUT, I cannot get it to output an {% else %} section (e.g. if customer orders has line item that contain specific tag show information else do X).

{% for order in customer.orders %}
{% for line_item in order.line_items %}
{% if line_item %}
<h3>You recently purchased<br>
{{ line_item.title }}</h3>
{% endif %}
{% for tag in line_item.product.tags %}
{% if tag contains 'Mix'%}
<p>Did you know?</p>
{% include 'tag-sonic-mixes-descriptors' %}

{% else %} Do X
{% break %}
{% endif %}
{% endfor %}
{% break %}
{% endfor %}
{% break %}
{% endfor %}

Thanks again. 

0 Likes