Simple Theme - Hide Empty Collections

Solved
Highlighted
Excursionist
34 2 3

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
Highlighted
Excursionist
34 2 3

Bump

0 Likes
Highlighted
Shopify Partner
1172 34 221

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

 

 

 

 

 

 

Available for hiring. Reach me at lixon@ecommercestudio.in
Highlighted
Excursionist
34 2 3

Thank a million!!!!

0 Likes
Highlighted

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
Highlighted
Shopify Partner
1172 34 221

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

Available for hiring. Reach me at lixon@ecommercestudio.in
0 Likes
Highlighted

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
Highlighted
New Member
4 0 0

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

0 Likes