Hiding empty collections in navigation menu refresh theme

Hello. I am setting up my Shopify store and need some help. I am wanting to hide collections that have no items in them automatically in the navigation menu. In other words, I don’t want my collection and navigation menu title to show up if the collection it is pointing to Contains zero items. I have found code for other themes but I need the code and how to do this in the refresh theme. Can someone help me with this? Any help would be greatly appreciated! Thank you.

Hello @Harbolt ,

You can achieve the goal of automatically hiding collections with no items in them from the navigation menu by customizing your theme. The process involves modifying your theme’s code to implement this functionality. Please note that modifying your theme’s code requires some technical knowledge, and it’s recommended to back up your theme before making any changes

Here is sample code you can take an idea from it.


  {% for collection in collections %}
    {% assign collection_has_items = false %}
    {% for product in collection.products %}
      {% if product.available %}
        {% assign collection_has_items = true %}
        {% break %}
      {% endif %}
    {% endfor %}
    {% if collection_has_items %}
      - {{ collection.title }}
    {% endif %}
  {% endfor %}

Thanks

On other posts, the people on the board walked the others through exactly what to do. I tried following the one for the Minimal theme but they were requiring the code to be pasted into a site.NAV file which is not in my refresh theme. That is why I was asking for someone to walk me through the steps on which files to put the code and so forth.

Check what they asked for a quick fix for css or something which can be fixed just by checking the store front.