I’m looking for advice on how to hide multiple collections from the All Collections List, using a True/False metafield at the collection level.
I’m hoping there is a way to utilize the metafield so that when it is FALSE, the collection is not hidden; but can only be accessed through a URL link if set to TRUE (metafield key is custom.hide_collection_from_storefront ).
Instructions
-
Go to ‘Online Store’ → Themes
-
From your Active Theme → Click on the 3 dots (…) → Edit Code
-
In the Sections Folder locate the file called ‘main-list-collections.liquid’ or something similar
-
Find the below for loop
{%- for collection in collections -%}
- {% render 'card-collection',
card_collection: collection,
media_aspect_ratio: section.settings.image_ratio,
columns: 3
%}
{%- endfor -%}
- Surround everything inside the for loop with this:
{%- for collection in collections -%}
{% if collection.metafields.custom.hide_collection_from_storefront.value == false %}
- {% render 'card-collection',
card_collection: collection,
media_aspect_ratio: section.settings.image_ratio,
columns: 3
%}
{% endif %}
{%- endfor -%}
Hope this helps
Oh my gosh thank you so much!! I’ve been trying to figure this out ALL day. What you suggested worked immediately and your explanation was basically foolproof.
1 Like