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.
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024