Hide Products with tag from collection pages + Search Results

Solved

Hide Products with tag from collection pages + Search Results

Intheflow
Shopify Partner
8 0 2

Hey! 

 

I'm putting together a wholesale Private collection on my page. It is all working as I was hoping however I now need to hide the products with the tag 'wholesale' from the main and featured collections, product recommendations and search results.

 

I'm using the Califonia Theme, so assume I will need to implement some code to hide these products to the following pages - sections/main-collection.liquid, sections/product-recommendations.liquid, sections/featured-collection.liquid and sections/search.liquid.

 

If anyone has suggestions on how to edit these, or if you suggest I go another way about this I'm open to suggestions! 

 

Thank you!!

Accepted Solution (1)

ProtoMan44
Shopify Partner
746 60 114

This is an accepted solution.

@Intheflow Hey, thanks for posting here.

you can use this method on all product loop : 

{% for product in collection.products %}
  {% assign exclude_product = false %} <!-- Default to false -->

  {% for tag in product.tags %}
    {% if tag == 'wholesale' %}
      {% assign exclude_product = true %}
    {% endif %}
  {% endfor %}

  {% if exclude_product == false %}
    <!-- Product display code here -->
  {% endif %}
{% endfor %}

 

- A thirsty developer passionate about supporting the community. If you'd like to, you can  

Buy me a Coffee.


- Your Shopify Solution Specialist Get a Quote at

ProtoMan44

 - 

Chat On Whatsapp


Crafting exceptional e-commerce experiences to elevate your online presence. Let's build your success story together!

View solution in original post

Replies 6 (6)

Guleria
Shopify Partner
4167 811 1168

Hello @Intheflow ,

 

Yes you are right you need to add code in these files.

But it's hard to provide instructions for it.

I suggest reaching out to app support or go with a developer.

 

Problem solved don't forget to Like it and Mark it as Solution!
If you need help with customization/code part you can contact me for services

You can find the email in the signature below.

 

Regards
Guleria 

- Custom themes, UI/UX design, ongoing maintenance & support.
- Drop an email   if you are looking for quick fix or any customization
- Email: guleriathakur43@gmail.com Skype: live:navrocks1
- Try GEMPAGES a great page builder

ProtoMan44
Shopify Partner
746 60 114

This is an accepted solution.

@Intheflow Hey, thanks for posting here.

you can use this method on all product loop : 

{% for product in collection.products %}
  {% assign exclude_product = false %} <!-- Default to false -->

  {% for tag in product.tags %}
    {% if tag == 'wholesale' %}
      {% assign exclude_product = true %}
    {% endif %}
  {% endfor %}

  {% if exclude_product == false %}
    <!-- Product display code here -->
  {% endif %}
{% endfor %}

 

- A thirsty developer passionate about supporting the community. If you'd like to, you can  

Buy me a Coffee.


- Your Shopify Solution Specialist Get a Quote at

ProtoMan44

 - 

Chat On Whatsapp


Crafting exceptional e-commerce experiences to elevate your online presence. Let's build your success story together!
Intheflow
Shopify Partner
8 0 2

Thank you for helping! 

 

So for example where would I Implement this in the following code?

 

<div class="content {% render 'content-classes', scope: section %}" data-section-id="{{ section.id }}" data-section-type="collection">
{% paginate collection.products by section.settings.products_per_page %}
{% render 'collection', products: collection.products, paginate: paginate %}
{% endpaginate %}
</div>

{% schema %}
{
"name": "t:sections.main-collection.name",
"settings": [
{
"type": "header",
"content": "t:sections.main-collection.settings.header__1.content"
},
{
"type": "paragraph",
"content": "t:sections.main-collection.settings.paragraph.content"
},
{
"type": "checkbox",
"id": "show_collection_image",
"default": false,
"label": "t:sections.main-collection.settings.show_collection_image.label",
"info": "t:sections.main-collection.settings.show_collection_image.info"
},
{
"type": "checkbox",
"id": "show_collection_description",
"label": "t:sections.main-collection.settings.show_collection_description.label",
"default": true
},
{
"type": "header",
"content": "t:sections.main-collection.settings.header__2.content"
},
{
"type": "range",
"id": "columns_desktop",
"min": 1,
"max": 6,
"step": 1,
"default": 4,
"label": "t:sections.main-collection.settings.columns_desktop.label"
},
{
"type": "range",
"id": "columns_tablet",
"min": 1,
"max": 4,
"step": 1,
"default": 3,
"label": "t:sections.main-collection.settings.columns_tablet.label"
},
{
"type": "range",
"id": "columns_mobile",
"min": 1,
"max": 3,
"step": 1,
"default": 2,
"label": "t:sections.main-collection.settings.columns_mobile.label"
},
{
"type": "range",
"id": "products_per_page",
"min": 8,
"max": 24,
"step": 4,
"default": 12,
"label": "t:sections.main-collection.settings.products_per_page.label"
},
{
"type": "header",
"content": "t:sections.main-collection.settings.header__3.content"
},
{
"type": "checkbox",
"id": "enable_filtering",
"label": "t:sections.main-collection.settings.enable_filtering.label",
"info": "t:sections.main-collection.settings.enable_filtering.info",
"default": false
},
{
"type": "checkbox",
"id": "enable_sorting",
"label": "t:sections.main-collection.settings.enable_sorting.label",
"default": false
},
{
"type": "checkbox",
"id": "show_labels",
"label": "t:sections.main-collection.settings.show_labels.label",
"default": true
},
{
"type": "header",
"content": "t:sections.main-collection.settings.header__4.content"
},
{
"type": "paragraph",
"content": "t:sections.main-collection.settings.paragraph.content"
},
{
"type": "header",
"content": "t:sections.settings.header.content"
},
{
"type": "checkbox",
"id": "show_background",
"label": "t:sections.settings.show_background.label",
"default": false
},
{
"type": "checkbox",
"id": "expanded",
"label": "t:sections.settings.expanded.label",
"default": true
}
]
}
{% endschema %}

Guleria
Shopify Partner
4167 811 1168

Check file collection.liquid under snippets you will find loop there.

- Custom themes, UI/UX design, ongoing maintenance & support.
- Drop an email   if you are looking for quick fix or any customization
- Email: guleriathakur43@gmail.com Skype: live:navrocks1
- Try GEMPAGES a great page builder
Intheflow
Shopify Partner
8 0 2

That worked for the collection pages! Thanks @ProtoMan44 and @Guleria.

 

Could I do the same thing for the search.liquid?

ProtoMan44
Shopify Partner
746 60 114

@Intheflow depends on the structure.
it works if the search code method is related to liquid.



can you please mark It solved.
thanks.

- A thirsty developer passionate about supporting the community. If you'd like to, you can  

Buy me a Coffee.


- Your Shopify Solution Specialist Get a Quote at

ProtoMan44

 - 

Chat On Whatsapp


Crafting exceptional e-commerce experiences to elevate your online presence. Let's build your success story together!