Need help coding a private collection for tagged customers

Need help coding a private collection for tagged customers

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

Replies 2 (2)

NomtechSolution
Astronaut
1245 113 160

The issue in your code seems to be with the quotation marks around the tag name 'laybuy'. In the code you provided, you're using a different type of quotation marks (smart quotes) instead of regular single quotes.

To fix the issue, replace the smart quotes with regular single quotes. Here's the corrected code:

{% if customer.tags contains 'laybuy' %}
  {% section 'collection.laybuys' %}
{% else %}
  {{ pages.no-access.content }}
{% endif %}
shelleyd
Explorer
90 1 17

Thanks, but no, that didn't work. I'm getting this error message on the live website now:

 

Liquid error (templates/collection.laybuys line 2): Error in tag 'section' - 'collection.laybuys' is not a valid section type