Why can't I access my private collection with the laybuy tag?

Why can't I access my private collection with the laybuy tag?

shelleyd
Explorer
90 1 17

I've been using this guide (How to create a private collection for tagged customers – Sunbowl (sunbowlsystems.com) ) 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 %}
{{ pages.no-access.content }}
{% 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?

 

Shelley

Reply 1 (1)

NomtechSolution
Astronaut
1245 113 153

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 %}
  {{ pages.no-access.content }}
{% 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.