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:
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.
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.
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.
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.
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.
This answer might be very late but I stumbled on this topic today and the snippet given from Sweet_Savior_3 has been helpful to me.
To avoid the disappearance of the pricing filter is enough to add an “or” clause to the code in the line 114:
{% if filter.values.size > 1 or filter.type == ‘price_range’ %}