What's your biggest current challenge? Have your say in Community Polls along the right column.

Re: Hide a specific filter on a specific collection page

Hide a specific filter on a specific collection page

StatusSkateshop
Visitor
2 0 0

My online skateboard shop utilizes several custom product filters. I'm using Dawn 2.0.

 

My custom filters are defined as product metafields. I have the Search & Discovery App installed which works well to automatically display the relevant filter values on collection pages that contain products that have the associated filter value set.

 

However, there are a few situations where I'd like to explicitly hide a particular filter value on a specific Collection page as only a limited number of products in the collection have that value set.

 

For instance, on this Skateboard Deck collection page both Deck Width and Wheelbase Filters are correctly being shown:

 

https://statusskateshop.com/collections/skateboard-decks

 

I'm trying to completely hide the Wheelbase Filter selection widget for this specific collection page while leaving the Availability, Brand and Deck Width Filters intact.

 

Basically a few of the products that appear in this collection will also appear in other collections where wheelbase is a very relevant filter that applies to all the other items in that collection. However, the vast majority of products in this specific collection will not have a wheelbase filter value set, so it is misleading to use the filter and only see a few results appear.

 

Thanks in advance for any advice!   

 

 

 

 

 

Replies 9 (9)

Sweet_Savior_3
Shopify Partner
1361 104 144

Hello @StatusSkateshop 

 

Welcome to Shopify Community.

 

So you can search for facets.liquid file and can add the condition if {% if filter.values.size > 1 %}{% endif %} like this:

Sweet_Savior_3_1-1712249904543.png

 

Sweet_Savior_3_0-1712249862902.png

 

Let me know if you face any issue with editing the code.

 

Thanks

 

 

Don't forget to like and accept the solution to help others store owners.
Looking for an expert or Have any queries ? Send query to the Inbox
Coffee Tip ? Pay to shopify.dev.34@gmail.com
From Less To Further !!!
StatusSkateshop
Visitor
2 0 0

Hi @Sweet_Savior_3 , I appreciate the welcome and response.

 

This certainly looks like the right spot to insert logic that would either remove the particular filter from the filter list or add some code to hide the display of that filter.

 

I'm looking for flexibility to do this for other similar cases as well, so the solution I'm hoping for would work regardless of how many relevant filters remain. There also many other collections where all filters should be displayed. 

 

I was thinking something that would explicitly match the current collection name and then explicitly remove/hide the filter by name. I just don't have the familiarity with Liquid to figure it out. 

 

   

Sweet_Savior_3
Shopify Partner
1361 104 144
Yes, it can be done but its needs custom code setup and you will have to
seek help with a developer to setup this with the theme at reasonable cost.
So it will be created with settings for you to manage in the future too.

Let me know if I can help you in anyways.
Don't forget to like and accept the solution to help others store owners.
Looking for an expert or Have any queries ? Send query to the Inbox
Coffee Tip ? Pay to shopify.dev.34@gmail.com
From Less To Further !!!
sabrina1912
Visitor
2 0 0

Hi! This code works, however it causes the pricing filter to disappear. Any advice?

Bahia_Designs
Shopify Partner
7 0 2

You should be able to assign any collections you don't want to include the filter in into an array, and then write an unless statement that says unless the collection is within this array and the filter label is 'Wheelbase', execute the theme code. So essentially, it will not execute the filter code for 'Wheelbase' if the current collection is within the array.

 

The code might look something like this:

 

{%- assign special_collections = 'Skateboard Decks,Longboard Decks,Cruiser Decks ' | split: ',' -%}

{%- unless special_collections contains collection.title and filter_label == 'Wheelbase' -%}

 

rest of the theme code that displays the filter

 

{%- endunless -%}

 

At Bahia Designs, we create beautiful and usable digital experiences for innovative brands. Shopify Partners since 2013.

Kairike
Shopify Partner
3 0 0

Hi community!

 

I have a similar request.

 

I'm using two filters: "Brand" (Vendor) and "Product" (Product type). Both brands and products are collections. I would like to hide "Brand" filter on the brand pages where there is one specific brand (and you cannot choose any other). And "Product" filter on product pages as it's unnecessary to display it.

 

Any idea how I could do that?

 

Thank you in advance!

K.

 

Screenshot 2024-09-05 at 13.17.51.png

Sweet_Savior_3
Shopify Partner
1361 104 144
It can be done with some code tweaks.
Don't forget to like and accept the solution to help others store owners.
Looking for an expert or Have any queries ? Send query to the Inbox
Coffee Tip ? Pay to shopify.dev.34@gmail.com
From Less To Further !!!
zeinaN
New Member
8 0 0

hey i need help with my code please

 ..i want to remove shop by brand in a specific brand page ..same to the other filters

Sweet_Savior_3
Shopify Partner
1361 104 144
Sure please feel free to connect to the inbox mentioned in below signature.
Don't forget to like and accept the solution to help others store owners.
Looking for an expert or Have any queries ? Send query to the Inbox
Coffee Tip ? Pay to shopify.dev.34@gmail.com
From Less To Further !!!