每个标签的购物计数 [英] Shopify counts per tags

查看:12
本文介绍了每个标签的购物计数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是购物新手,我加了黑色、蓝色、绿色等标签。 现在我想显示Count Like

黑色(12)

蓝色(%1)

绿色(4)

有没有人帮我

谢谢

推荐答案

我对类似问题的回答可能对您有帮助:Shopify Tags total items

若要获取具有给定标记的所有产品的计数,您需要遍历产品并手动计数。

例如:

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

这篇关于每个标签的购物计数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆