【问题标题】:Shopify counts per tags每个标签的 Shopify 计数
【发布时间】:2014-06-11 23:49:13
【问题描述】:

我是 shopfiy 的新手。我添加了黑色、蓝色、绿色等标签。 现在我想显示类似的计数

黑色(12)

蓝色(1)

绿色(4)

有人帮帮我吗

谢谢

【问题讨论】:

    标签: shopify


    【解决方案1】:

    我对类似问题的回答可能会对您有所帮助: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 %}
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-09
    • 2016-07-26
    • 1970-01-01
    • 2020-07-12
    • 2015-07-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多