Contains not working to find a substring of a product tag

New Member
5 0 0

Hey guys, good day!


I am facing an issue with the contains for a product tag that includes ":" , could this be an issue with the operator or is this documented somewhere?


for example if a product has the following tag config:max_quantity_per_order:10 and I check if the product contains a sub string of this tag using `product.tags contains "config:max_quantity_per_order" or "config:max_quantity_per_order:" it doesn't work it returns false.


Have any of you guys faced a similar issue?


Thanks in advance for any help!

31 0 3

for    :    the character code is       :

New Member
5 0 0

I think you are referring to something else. I am talking about liquid code to search for specific tag in a product. I found that if the tag contains ":" it does not work when checking in product.tags, if you do a for tag in product.tags and check there it works. I might create an Issue directly in github to get more info.

Shopify Expert
2686 67 689

Just did a test and this code:

    {% if product.tags contains "config:test" %}
    <p>Contains "config:test" tag</p>
    {% endif %}

works properly at my test site 

So it's not a problem with semicolon.


However, you're running contains check against product.tags, which is an array and in this case the match must be exact (like it is in my example), you can't match a substring when using contains with arrays.

So you may do it like this:

{% assign tags_string =  tags | join: "|||" %}
{% if tags_string contains "config:max_quantity_per_order:" %}
  {% assign max_qty = tags_string | split: "config:max_quantity_per_order:" | last | times: 1 %}
{% if max_qty > 0 %} <!-- limit max qty to {{ max_qty }}! -->
{% endif %} {% endif %}


Want to hire me to tweak a theme? Mail me at!
My post solved your problem? Like it!
I am away till Feb-15.
1 Like
New Member
5 0 0

Thanks @tim that confirms the weird behavior that I was experiencing. So if it is for a specific tag in a for loop contains correctly works as a substring.


If it is for .tags which is an array, it stops working as a substring and works as an exact match. 


Very inconsistent if you ask me.


Thank you!