Hide Empty Collections

Highlighted
Shopify Partner
10 0 2

In regards to the main collections page (www.domain.com/collections/) I want to hide all of the collections that have 0 items available. Now, those collections may have products associated with it, but they are not visible on the site. Having some trouble with the liquid code to make these collections with 0 items to be hidden on the main collections page. Right now it shows all 20 collections, regardless of whether or not items are turned on.

So if there are only 3 collections that have visible products, this main collections page should only display those three.

Highlighted
Shopify Partner
10 0 2

I know that I can simply "HIDE" the collections via the collections page in the CMS, but was checking to see if there was another way to do it programatically.

0 Likes
Highlighted
Astronaut
1890 1 442

You can use a conditional statement to check the number of products in the collection.  I can't give any specifics since you didn't specify a theme.  You might end up with something like this:

{% for collection in collections %}
  {% unless collection.products.count < 1 %}
    {% include 'collection-grid-item' %}
  {% endunless %}
{% endfor %}

 

Highlighted
New Member
1 0 0

hi, m new to shopify , n also want to hide collections if there is no products in it.. I had installed 
FURNIMART SHOPIFY THEME and m using quikify app for nevigation as we had lots of menus... 

Above you suggested the code for it.. can you please mention where to add it ?

It will be really heplfull for us.

Thank you

0 Likes
Highlighted
Tourist
3 0 1

hey @pranjaljanrao, i'm not familiar with furnimart and quikify, but i was able to use this post from @Lixon_Louis to edit my code!

you might also try reaching out to support for your theme (if it exists) or hiring a Shopify Expert if that doesn't work!

0 Likes