How to Display only products with specific tag in the collections

Solved
Highlighted
New Member
3 1 1

Hello, 

SO i want to display the products that contains a tag "test"  for only the clients with tag "Group-2"  in all the collections, for example the collection all will show only the products with tag "test" if the customer have tag "Group-2", i was able to do that but the problem is the product is showing on page 3 for example like there is all the products so it shows the count for all the products but display one, so i get 3 pages the first two empty , here is the code i hope someone can help me with this issue thanks in advance 

{% if customer.tags contains 'Client-Group-2' %}  
                  
<div class="product-list product-list--collection">
      {%- for product in collection.products  limit: product_limit-%}
    		  {% for tag in product.tags %}
                        {% if tag contains "test"  %} 
                              {%- render 'product-item' -%}  
  				{% else %}
 				 {% continue %} 
  				{% endif %}     
			 {% endfor %}       
      {%- endfor -%}   

   </div> 
            {% else %}
 <div class="product-list product-list--collection ">
                      {%- for product in collection.products -%}
                         {%- render 'product-item' -%}  
                      {%- endfor -%}   
   </div> 
{% endif %}  
0 Likes
Highlighted
Shopify Partner
118 17 26

Hi @Heisenberg 

Please try following


{% if customer.tags contains 'Client-Group-2' %} 
<div class="product-list product-list--collection">
{%- for product in collection.products limit: product_limit-%}
{% for tag in product.tags %}
{% unless tag != "test" %}
{%- render 'product-item' -%}
{% endunless %}
{% endfor %}
{%- endfor -%}
</div>
{% else %}
<div class="product-list product-list--collection ">
{%- for product in collection.products -%}
{%- render 'product-item' -%}
{%- endfor -%}
</div>
{% endif %}

 

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Click Accept as Solution

Skype : lokendra.panwar1
0 Likes
Highlighted
New Member
3 1 1

same problem it shows the product but it display it on the third page while page 1  and 2 empty 

0 Likes
Highlighted
Shopify Partner
118 17 26

Need to look at liquid files and recheck the logic of rendring

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Click Accept as Solution

Skype : lokendra.panwar1
0 Likes
Highlighted
New Member
3 1 1

This is an accepted solution.


@Propero wrote:

Need to look at liquid files and recheck the logic of rendring


I was able to fix it even i used another way with collections, here is how i solved it : 

{% if customer.tags contains 'Client-Group-2' %}  
                  
<div class="product-list product-list--collection">
 
      {%- for product in collections.group-2.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 %}                
1 Like