Automatically Hide empty collections in navigation on Shopify Impulse Theme

dh_harrypapas
Tourist
10 1 1
I would like to automatically hide empty collections in Shopify Impluse theme.

Here is the code, but I can't work out how get the amount of products in the collection

 

 

     {%- for grandchildlink in childlink.links -%}  
                    <div>
                      <a href="{{ grandchildlink.url }}" class="site-nav__dropdown-link">
                        {{grandchildlink.title}}
                      </a>
                    </div>
                  {%- endfor -%}
                {%- endfor -%}

 

Reply 1 (1)

Nyshawn
Shopify Partner
91 3 3
{% if collection.products.size == 0 %}  {% assign collection_url = '' %} {% else %}  {% assign collection_url = '/collections/' | append: collection.handle | append: '?view=all' | prepend: shopify_domain %} {% endif %>  &lt;a href="{{collection_url}}"&gt;View all {{collection.title}}&lt;/a&gt;

Should look something like this. 

banned