Hello,
I want to Hide empty collections in my navigation menu. I tried something like:
{% for collection in collections %}
{% if collection.all_products_count == 0 %}
.
.
.
{% endif %}
{% endfor %}
but the collections still show up, even if they contain no products.
Here is the complete code for the navigation bar:
{%- assign featured_links = section.settings.nav_featured_link | split: ', ' -%}
{% render 'svg-x' %}
{% for link in linklists[section.settings.menu_linklist].links %}
{%- assign has_dropdown = false -%}
{%- if link.links != blank -%}
{%- assign has_dropdown = true -%}
{%- endif -%}
{%- assign use_columns = false -%}
{%- if link.levels >= 2 -%}
{%- assign use_columns = true -%}
{%- else -%}
{%- for block in section.blocks -%}
{%- if block.settings.dropdown_link_title == link.title -%}
{%- assign use_columns = true -%}
{%- assign has_dropdown = true -%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
- {{- link.title -}}
{% if has_dropdown %}
{% render 'icon-toggle-menu' %}
{% endif %}
{% if has_dropdown %}
{%- assign promo_count = 0 -%}
{%- capture menu_promotion_html -%}
{%- for block in section.blocks -%}
{%- if block.settings.dropdown_link_title == link.title -%}
{%- assign promo_count = promo_count | plus: 1 -%}
{%- if block.settings.link_url != blank -%}
{%- endif -%}
{%- render 'responsive-image', image: block.settings.image -%}
{%- if block.settings.title != blank -%}
{{ block.settings.title }}
{%- endif -%}
{%- if block.settings.link_url != blank -%}
{%- endif -%}
{%- endif -%}
{%- endfor -%}
{%- endcapture -%}
{%- assign column_count = promo_count | plus: link.links.size -%}
{% for child_link in link.links %}
- {{- child_link.title -}}
{% if child_link.links != blank %}
{% render 'icon-toggle-menu' %}
{% endif %}
{% if child_link.links != blank %}
{% for child_child_link in child_link.links %}
- {{ child_child_link.title }}
{% endfor %}
{% endif %}
{% endfor %}
{%- if promo_count > 0 -%}
- {{ menu_promotion_html }}
{%- endif -%}
{% endif %}
{% endfor %}
While this is the part i am trying to change:
{% for child_link in link.links %}
- {{- child_link.title -}}
{% if child_link.links != blank %}
{% render 'icon-toggle-menu' %}
{% endif %}
{% if child_link.links != blank %}
{% for child_child_link in child_link.links %}
- {{ child_child_link.title }}
{% endfor %}
{% endif %}
{% endfor %}
{%- if promo_count > 0 -%}
- {{ menu_promotion_html }}
{%- endif -%}
I hope you can help me with this.

