I am outputing a value based on collection title in shopify
{% for collection in product.collections %}
{% if collection.title contains "China" %}
This is china
{% endif %}
{% endfor %}
{% for collection in product.collections %}
{% if collection.title contains "China,vietnam" %}
This is china and vietnam
{% endif %}
{% endfor %}
But the issue iam facing is, it is outputing both values which is
1)This is china
2)This is This is china and vietnam
can someone help to check, where the issue is
But the issue iam facing is, it is outputing both values which is
1)This is china
2)This is This is china and vietnam
2
Answers
"China" is a subset of "China,vietnam". The question doesn’t specify the output you expect, but it seems like you should only iterate the products collection once and use two conditions:
I think you should try this code.