Shopify counts per tags

牧云@^-^@ 提交于 2019-12-20 05:10:21

问题


I am new to shopfiy.I have addded tags like Black, Blue, Green etc. Now i want to show count like

Black(12)

Blue(1)

Green(4)

Does anybody help me out

Thanks


回答1:


My answer to a similar question might help you with this: Shopify Tags total items

To get a count of all the products with a given tag you need to loop over the products and manually count them.

For example:

{% assign collection = collections.all %}

{% 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 %}

    <p>{{ tag }} ({{ products_count }})</p>
{% endfor %}


来源:https://stackoverflow.com/questions/24174401/shopify-counts-per-tags

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!