Conditional Metafields or IF condition - Filtering

Hi all,

I’m creating an auto parts store and trying to organise my filtering. My products should display based on the make, model and year of vehicle.

To filter Make I’m using the collection. eg. Ford, Nissan etc

To filter Model I’m using a multi list metafield on the product page eg. Ranger, Raptor etc.

This works well together because for example when searching Make = Ford, only Ford models are shown.

The issue I have is when adding year. For example one product may be compatible with a Ford Raptor 2018-2024 but also a Ford Ranger 2013-2022. Because Raptors and Rangers have different production dates I don’t want the dates to spill over into the filter results of other models.

I’ve added another customer metafield to the product called “Year”. My question is, is there a way to link or only display this IF the model associated to that Year is chosen? I don’t want Years for Rangers being displayed if Model Raptor is chosen.

I guess what I’m asking for is conditional metafields on products or some kind of IF condition on metafields.

Thanks

Hi @alborg :waving_hand: unless a theme or an app specifically has this feature an advanced theme customization is required to get conditional filter behavior.

One kludge is to just combine model and years.

Filters and filter-values will show based on all eligible products in a collection.

This does mean that when a collection is filtered to Make = Ford all models and all years will show.

In your example if someone has a collection filtered to Make = Ford, Model = Raptor, and Year = 2024 in most cases that should only show products that fit that criteria.

If you need advanced theme customizations for presenting filters then contact me for services
Contact info in forum signature.
ALWAYS please provide context, examples: store url, theme name, post url(s) , or any further detail in ALL correspondence.

Good Luck.

Thanks for the reply Paul.

Kludge - I did think about doing it this way

“In your example if someone has a collection filtered to Make = Ford, Model = Raptor, and Year = 2024 in most cases that should only show products that fit that criteria.”

Yes the products results will still be correct . My challenge is imagine Product A is compatible with both Ford Raptor 2018 and Ford Ranger 2023. Ford (make) is dealt with by collection. I have one metafield each for Ranger and Raptor. I can also add a metafield for 2018 and 2023.

What I’d like to avoid is when someone filters Make=Ford Model=Raptor, only 2018 is active and available to be selected. Not 2018 and 2023 active and available to be selected.

I guess I could leave it like this show all years, the onus then is on the user to make sure they select the correct date. Probably a better look than kludging it and having “Raptor 2018” and “Ranger 2023” showing in the filter dropdown.

Will have a think, thanks.