Search code examples
shopifyshopify-appshopify-template

How to display products from specific tag in shopify?


How to display products from specific tag "organic" in shopify custom template? Here is my code.


{% if customer.tags contains 'organic' %}                    
<div class="product-list product-list--collection"> 
      {%- for product in collections.all.products  limit: product_limit-%}  
              {% for c in product.collections %}
          {% if c.title == collection.title %}
                              {%- render 'product-item' -%}  
            {% endif %}  
            {% endfor %}  
              {% if collection.handle=="all" %}
                           {%- render 'product-item' -%} 
                {% endif %}  
      {%- endfor -%}   
   </div>            
{% else %}
 <div class="product-list product-list--collection 
                                {% if has_filters %}
                                product-list--with-sidebar
                                {% endif %}">
                      {%- for product in collection.products -%}
                                  {%- render 'product-item' -%}
                      {%- endfor -%}   
   </div> 
{% endif %}

Solution

  • {% for product in collections.all.products %}   
    {% if product.tags contains "organic" %} 
     {% include 'product-list-item' %}  
    {% endif %}
    {% endfor %}