"if customer.tags contains" does not search for a tag

Topic summary

A user is implementing tag-based access control for a private collection in Shopify, restricting it to customers with a ‘vip’ tag. The initial {% if customer.tags contains 'vip' %} condition failed to recognize tagged customers.

Solution provided:

  • Replace single quotes with double quotes: "vip" instead of 'vip'
  • Downcase tags for consistent matching: {% assign customersTagsDowncase = customer.tags | downcase %}
  • Loop through tags if needed for more robust checking

This resolved the original issue successfully.

Related problem raised:
While collection-level protection works when users navigate through the site menu, customers can bypass restrictions by accessing individual product URLs directly (e.g., via Google search). The template page option doesn’t appear in the product template dropdown, and there’s no clear method to hide restricted products from untagged users when accessed via direct links rather than through the protected collection page.

Summarized with AI on November 8. AI used: claude-sonnet-4-5-20250929.

Some additional steps to try

First replace backquotes with simple quotes "

{% if customer.tags contains ‘vip’ %}
{% if customer.tags contains "vip" %}

then try downcasing all the tags so matching is more consistent

{% assign customersTagsDowncased = customer.tags | downcase %}
{% if customersTagsDowncased contains "vip" %}
 
{% endif %}

If that does not work, loop over all tags for the check, wrap the following around thelogic

{% for tag in customer.tags %}
 {% if tag == "tagname" %}

 {% endif %}
{% endfor %}
5 Likes