Django experts - need your help!
Hi guys,
This is for the Order Confirmation email (Shopify).
My goal is to use the FOR loop and loop through all the items in the order and check item.variant_title.
- If at least one variant_title has any of the following words: 'ebook', 'e-book' etc - display message A.
- If none of variant_titles has any of those words, display message B.
Important: this has to display only one message - A or B, no matter how many items are in the order. But NOT one message per every line item. So that's why I am using the "with" operator here and the if/else conditions.
The code looks fine, but Klaviyo gives an error, maybe something is not supported?
Thanks!
{% with contains_physical_book = False %}
{% for item in event.extra.line_items %}
{% if 'e-book' not in item.variant_title|lower and 'ebook' not in item.variant_title|lower and 'audiobook' not in item.variant_title|lower and 'audio book' not in item.variant_title|lower %}
{% with contains_physical_book = True %}
{% endwith %}
{% endif %}
{% endfor %}
{% if contains_physical_book %}
Message A
{% else %}
Message B
{% endif %}
{% endwith %}
