WooCommerce - range filter for product attribute

WooCommerce - I have an e-shop with board games and I have an product attribute “Players count”. I need a filter with this behavior:
Customer sets the filter to “2 - 5 players”,
the filter will show all the games they have players count like: 1 - 3 players, 3 - 6 players, 3 players, …
The best way is range filter like for price.
Ideal variant is Bricks native AJAX filter (and some custom code).

If you have a custom field on the product for player count, you can use the new Filter - Range element.

Sadly, it’s product attribute, not custom field.

Aren’t attributes just taxonomies?

1 Like

As long as you can query it with Bricks dynamic data you should be able to use filters.

@Illarion @GrowPlugins
I can filter by players count with checkbox-like filters. But I need to achieve this behavior:
Customer sets the filter to “2 - 5 players”,
the filter will show all the games they have players count like: 1 - 3 players, 3 - 6 players, 3 players, …
Pseudo code:
game_players_count_from <= filter_players_count_to AND game_players_count_to >= filter_players_count_from

Try the Filter - Range element.

You can review the information on the following videos.

No. :frowning:
Product attributes are in postmeta table in some structure format:

@GrowPlugins Range filter accepts only custom fields, I can’t set it up to accept product attribute.

It sounds like you will need to create a custom PHP function to query your data, and then call it as Dynamic Data using the echo function ({echo: some_function()}). But the exact code you will need to use I don’t know.

I know you will need to use unserialize() to convert that data into an array.

I haven’t tested this, but you may be able to use the meta query setting to get what you want. You will need to know how the meta data is stored.