Simple Theme - Hide Empty Collections

Solved
gchaney
Excursionist
35 2 4

Website: Juststuffisell.com

 

Using the simple theme. 

 

Working on finishing up the configuration for the new site and need some assistance with a few things. First one is I need to be able to hide empty collections and sub-collections automatically and to have them repopulate as items are added to them. 

 

I've tried a couple of processes for other themes that did not work in this one and was not able to find one that was done for the simple theme.

 

Any help would be greatly appreciated :)

 

0 Likes
gchaney
Excursionist
35 2 4

Bump

0 Likes
Lixon_Louis
Shopify Partner
1186 35 253

This is an accepted solution.

You can hide the empty collections using the condition below.

 

{% if collection.products_count != 0 %}
...
{% endif%}

Take  https://juststuffisell.com/collections  as an example . The code is in sections/list-collections-template.liquid in Simple theme. I have added this condition inside the loop before the grid__item . You can use the same logic if you are using blocks too.

screenshot-nichegeek.myshopify.com-2020.01.png

 

 

 

 

 

 

gchaney
Excursionist
35 2 4

Thank a million!!!!

0 Likes
shopany
Tourist
15 0 0

Hi Lixon_Louis

 

I was so happy to find your solution here and I tried immediately, but unfortunately it doesn't work on my side. I have the Theme DEBUT (VERSION 11.0.1) installed. Could that be the reason? My code looks a little bit different, but not so much…

 

{% for collection in collections %}
    <li class="grid__item {{ grid_item_width }}">
        {% include 'collection-grid-item', collection_image_size: image_size %}
    </li>
{% endfor %}

this code I changed to…

{% for collection in collections %}
    {% if collection.products_count != 0 %}
        <li class="grid__item {{ grid_item_width }}">
            {% include 'collection-grid-item', collection_image_size: image_size %}
        </li>
    {% endif %}
{% endfor %}

I would be very grateful if you could take a look at it. Thank you in advance

Stefanos

0 Likes
Lixon_Louis
Shopify Partner
1186 35 253

The solution is same for Debut. I suppose your collections are not empty then. Or are you talking about inventory_quantity? @shopany 

0 Likes
shopany
Tourist
15 0 0

Hi @Lixon_Louis

 

Thank you for your fast reply.

The collections are empty. I have a lot of empty collection right now, because I have not finished assigning the products. There is inventory available, but it's not linked / allocated to the collection.

0 Likes
ntcrawler
Tourist
4 0 1

I may have missed something in this process. I edited my theme, went to the file that was listed in the example, and added the code:

{% if collection.products_count != 0 %}


Where it was suggested to add the code. I saved the file, refreshed and when i previewed my site, the empty menu items (collections) were still visible.
Is there something I am missing here? Please advise,




list-collections-template.liquidlist-collections-template.liquidLive SiteLive Site

Hi @Lixon_Louis I have the same issue.

I follow the code that you gave but still the empty collection is visible on sidebar.

Hope you can help us too.

Thank you!

0 Likes
JusticeJackie07
New Member
1 0 0

Below is How to Hide Empty Collections and display only collections that has more than one data count
<li> {% for collection in collections %}
{% if collection.products_count != 0 %}
<br><a href="{{ collection.url }}"> {{ collection.title }} <span class="count">({{collection.products_count}})</span></a>
{% endif%} {% endfor %} </li>

0 Likes