Hide Collection with zero products from Navigation

Hide Collection with zero products from Navigation

kai007
Shopify Partner
1 0 1
Hi everyone,
I added a custom sidebar Collection navigation to my Collections pages through snippets (liquid code). It all works well, but I would like to automate hiding a collection which has only products with zero product stock. Hope it makes sense.
 
I'm using the following code:
{% assign collections = "collection-" | append: collection.handle %}
<ul>
{% for link in linklists.collections.links %}
    <li><a href="{{ link.url }}">{{ link.title }}</a></li>
{% endfor %}
</ul>
 
Any idea how could I implement this, please? Thanks in advance. 
Reply 1 (1)

Kalen_Jordan
Shopify Partner
526 17 77

You might want to use a metafield on the collection to store the number of in stock products. Then you should be able to key off of that in your liquid logic. I could build out a workflow for you to automate the populating of that metafield using our app mesa if you're interested.