Hi, We have several collections as sub menus in the nested navigation, which may or may not have products in them or change over time. We want the navigation not to show those sub menu’s which have 0 products (also an option to hide if product is available, but inventory is 0)
{% if enabled_currencies or published_locales and locale_name != blank%}
{% form ‘localization’, id: “localization_form-header”, class: “currency-selector” %}
{% if published_locales and locale_name != blank %}
{% endif %}
{% if enabled_currencies %}
{% endif %}
{% endform %}
{% endif %}
{% for link in linklists[section.settings.menu].links %}
{%- liquid
capture cycleIndex
echo link.handle | append: ‘-’ | append: forloop.index
endcapture
assign sub_links = false
assign sub_sub_links = false
for sub_link in link.links
if link.links.size > 2
assign sub_links = true
endif
for sub_sub_link in sub_link.links
assign sub_sub_links = true
endfor
endfor
-%}
Hi, Thank you for the same. However, unfortunately, this solution only worked partially
For example, we have a parent collection in the navigation for Flowers, if we put a sub collection of Red in it without any products, then that sub collection does not show and this solution seems to work.
However, if Under Flowers, we put a Sub collection called Fresh Cut Flowers and under that we have different colour sub menu’s, including Red (with no products), then the collection for Red does show.
Hence, it works for Parent Menu->Sub Menu, but not for Parent Menu->Sub Menu->Sub-Sub Menu
Hi, Thank you for the quick solution. It worked. Very much appreciate the assistance. Request also for the following -
Could you direct us to the changes made in the liquid file for future reference? If there are future theme updates, it would help to know to incorporate the same at that time.
Currently, this solution hides the sub collections and the sub-sub’s if all the products in that collection are listed as 0 inventory, as opposed to having 0 products in a collection. Is it possible to show those collections which have 1 or some products (regardless of their inventory level being 0 or 1, etc) ?
There may be some products which may have status as ‘continue’ in order to continue selling regardless of inventory. How does it impact the navigation then?
Another issue we faced is that in the Avenue 2.0 theme, there is a collection tile on top on the collections page, Hence, once we click on a parent menu which has 3 sub menu’s of which, lets say, 1 doesn’t show in the navigation due to 0 inventory, then on the collection page atleast, the tile shows up. How do hide that as well?
Is it possible to make all these and/or other changes in separate smaller files in the theme, rather than the header.liquid file, or does that slow the site down?