Shopify Tags total items

后端 未结 2 1564
长发绾君心
长发绾君心 2021-01-15 06:48

In Shopify, how do I show a list of tags followed by the number of products with that tag?

Example: Black(12), Blue(10).

Currently the code looks like this,

2条回答
  •  被撕碎了的回忆
    2021-01-15 07:31

    Solution by Steph is working. But, if i have enabled grouped tags and want to show product count. Kindly let me know solution to append product count in following code:

    '{%comment%} code for color, designer, material sidebar filter {%endcomment%}
    
              {%- for tag in collection.all_tags -%}
                
                {%- assign tag_parts = tag | split: '_' -%}
    
                {%- if tag_parts.size != 2 -%}
                  {%- continue -%}
                {%- endif -%}
    
                {%- assign groups = groups | append: tag_parts.first | append: ',' -%} 
              {% endfor %}
    
    
        {%comment%} End of  code for color, designer, material sidebar filter {%endcomment%}'
    

提交回复
热议问题