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'
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.
I am trying to set up a “private collection” page that only customers with the ‘vip’ tag can view.
I created a new collection with the theme ‘private-collection’, then I added the code below on a new section called ‘collection.private-collection.liquid’:
{% if customer.tags contains ‘vip’ %}
{% section ‘collection’ %}
{% else %}
{{ pages.no-access.content }}
{% endif %}
I then tagged some customers as ‘vip’ but it does not seem to recognise the vip customers - no one is able to open the page.
I believe that “contains” in the first row does not work correctly, as all customers see the “else” option.
Hi Paul - I wonder if you can help me. I have done the same as above to “protect” veterinary subscription food products in a collection. If I go to the collection via the website it works but if anyone googles the vet product and clicks on the direct link to that products they can see it and buy it without having to have the tag.
I have been searching but I cannot find a way to hide all those products that are in that collection from un-tagged buyers so that they see the same “Apologies” page.
The page template does not appear in the product template dropdown and I am not sure how to go about it.