Hi there - woukd anyone know how to test if there is more that one product with a certain tag in /collections/all/{{ tag | handleize }}
I can do this where the tag has a collection like so, {% if collections[tag | handleize].products.size > 1 %} But I dont know how to do it if there isnt a matching collection
can anyone help with this ? thanks in advance
In my opinion there is only one way but it doesn’t work if you have too many products. Refer code:
{% for tag in collection.all_tags %}
{% assign products_count = 0 %}
{% for product in collection.products %}
{% if product.tags contains tag %}
{% assign products_count = products_count | plus: 1 %}
{% endif %}
{% endfor %}
{{ products_count }}
{% endfor %}
Hope it helps!