Problem with code for private collection

90 1 17

I've been using this guide (How to create a private collection for tagged customers – Sunbowl ( ) to set up a private collection available only to customers who are logged in and tagged 'laybuy' in my online store.


I've used the following code:


{% if customer.tags contains ‘laybuy’ %}
{% section 'collection.laybuys' %}
{% else %}
{{ }}
{% endif %}


I'm now at the testing stage, and I can't access the private collection. I think there may be an issue with the second line of coding.


Can someone please advise?



Reply 1 (1)
1245 111 139

The issue with your code might be due to the use of curly quotes instead of straight quotes in the condition. Replace the curly quotes (‘’) around the tag value 'laybuy' with straight quotes (''). Here's the corrected code:

{% if customer.tags contains 'laybuy' %}
  {% section 'collection.laybuys' %}
{% else %}
  {{ }}
{% endif %}

Make sure to update the code with straight quotes and then test it again. This should properly check if the customer is tagged with 'laybuy' and display the private collection if the condition is met. Otherwise, it will display the content from the no-access page.

Chat on WhatsApp: +923246370042
Need a Shopify developer?
For Shopify Design Changes | Shopify Custom Coding | Custom Modifications