Shopify themes, liquid, logos, and UX
I want to check if any of my products match a given array value.
Here's my product tag:
{% assign product_tags = product.tags | split: ',' %}
Here's my discount code:
{% assign discountCode = "50off, 100off, 150off, 200off, 250off, 300off, 350off, 400off, black_friday_2022" | split: ',' %}
What I have tried with:
{% for tag in product_tags %} {% if discountCode contains tag %} Extra in-Cart Discount {% endif %} {% endfor %}
Any help would be much appreciated
You are doing the right way, but the code need some changes
1. Remove spaces between discount codes
{% assign discountCode = "50off,100off,150off,200off,250off,300off,350off,400off,black_friday_2022" | split: ',' %}
2. We should break the loop if the match tag is found
{% for tag in product_tags %}
{% if discountCode contains tag %}
Extra in-Cart Discount
{% break %}
{% endif %}
{% endfor %}
Hope that helps!
Apparently the product_tags isn't recognized by flow.
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025