Skip to main content

Hello,

 

Here is what I want to achieve: I have a set of SKUs. I want to show a specific block of text only ONCE if the sku is matching one of the skus on my list.

I have this loop created:

{% for product in event.products %} {% for package in product.packages %}

{% if product.sku == '290002' or product.sku == '290003' or product.sku == '290004' %} Show this Text {% endif %}  {% endfor %}  {% endfor %}

But in this case, if there are multiple SKUs matching this search, the text will be shown multiple times. 

How do I make it show only once?

 

Thank you!

Thank you!


Hey @Nataliia 

Welcome to the community and congrats on your first post!

I would suggest changing the logic to an elif statement. Something like this will achieve your goal:
{% if product.sku == '290002' %} Show this Text {% elif product.sku == '290003' %} Show this Text {% elif product.sku == '290004' %} Show this Text {% endif %} {% endfor %}  {% endfor %}

Hope this helps!


Reply