Skip Navigation

[Resolved] Need Range filter in Toolset (from/till)

This support ticket is created 2 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 21 replies, has 2 voices.

Last updated by Luo Yang 2 years, 6 months ago.

Assisted by: Luo Yang.

Author
Posts
#2336303

Hi,

We are currently (re)building a car dealer website (hidden link). We have added the CPT with the custom fields and entered some items.
We now need to filter those items. The first 2 filters are quite straightforward, but now we need some from/till filters (mileage, year built, price) like in this example: hidden link

How can we build this?

#2336639
range-filter.jpg

Hello,

It is possible to setup range filter on numeric field, you just need to use "Between" comparison in the filter setting, see my screenshot: range-filter.JPG

#2337079
Screenshot_5.jpg
Screenshot_2.jpg
Screenshot_1.jpg

Hi,
I edited the range filter to match "number" and "between" but it does not reflect on the frontend. When I went back to check the settings, it showed String where I've chosen Number before.
Also, I was not able to delete 'kilometerstand' from the Query Filter.

Then I added the "Build Year" range filter in the same way (but choose Date instead of Number, does that work or does range only work with Number? So how to chose a Date range then?).
Now when I edit the "Mileage" range filter, it's "Number" again and no longer String, however, Build Year is now String and where I was unable to remove Kilometerstand from the Query Filter, I can now, but I can't remove Bouwjaar.

It seems like it's one or the other. But I need 3 range filters: Kilometerstand (mileage), Bouwjaar (build year) and Prijs (price).

#2338523

Toolset custom date field stores value in timestamp format, so you can use option "number" in date range filter, see our document:
https://toolset.com/documentation/user-guides/views/date-filters/

For the problem:

When I went back to check the settings, it showed String where I've chosen Number before.

The problem you mentioned above is abnormal, I suggest you try to create a new post view, and setup the custom search form again.
If you still need assistance for it, please provide a test site with the same problem, also point out the problem page URL and view URL, I can setup a demo for you.

#2343685

Thanks for the details, I am checking it in your website, will update here if find anything

#2343689

You can customize the options of those select fields, for example, edit the post view:
hidden link
section "Search and Pagination", line 13 and 17

change these two lines To:
[wpv-control-postmeta field="wpcf-kilometerstand" type="select" order="ascnum" url_param="wpv-wpcf-kilometerstand_min" source="custom" values="10, 15, 20" display_values="10.000, 15.000, 20.000"]
...
[wpv-control-postmeta field="wpcf-kilometerstand" type="select" order="ascnum" url_param="wpv-wpcf-kilometerstand_max" source="custom" values="15, 20, 25" display_values="15.000, 20.000, 25.000"]

You can follow our document to setup the attributs
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-control-postmeta
'database' | 'custom'
Defines the origin of the offered values to offer. Can be database or custom.
...
values (opt):
comma separated list of option values
...
display_values (opt):
comma separated list of option display values

#2346073

I have looked at the documentation but it's lacking some useful examples, so I am still struggling with this range filter.
I have set the values and display_values for both the FROM and the TO mileage fields.

	[wpv-control-postmeta field="wpcf-kilometerstand" type="select" order="ascnum" url_param="wpv-wpcf-kilometerstand_min" source="custom" values="0, 2500, 5000, 10000, 15000, 20000, 25000" display_values="van, 2.500 km, 5.000km, 10.000 km, 15.000 km, 20.000 km, 25.000 km"]
	[wpv-control-postmeta field="wpcf-kilometerstand" type="select" order="ascnum" url_param="wpv-wpcf-kilometerstand_max" source="custom" values="200000, 2500, 5000, 10000, 15000, 20000, 25000" display_values="tot, 2.500 km, 5.000km, 10.000 km, 15.000 km, 20.000 km, 25.000 km"]

However, when I select a minimum value of 10.000 so it filters to only the 2nd vehicle, the filter says no items found. Same when I set to max 10.000km, it should only display the first vehicle but again says no items found.

#2346673

The problem isn't in "kilometerstand" field, it should be in other filters, I have tried again in your website:
hidden link
change any other filter, it always return result: No items found

I suggest you remove other filters one by one, try to locate the problem filter.

#2348573

These multiple filters are very buggy and unpredictable 🙁

1/ I have deleted the Bouwjaar (Build Year) filter from Search and Pagination. It was still present in the Query Filter so I manually deleted it there.
2/ I have checked the Price filter, it always reverts back to String equal to instead of number between lower/higher end.
3/ I cannot edit that filter in Query Filter, it just says "Filter based on the frontend search filter by Prijs."
4/ I cannot manually add the Price filter in Query Filter because "Price" is already taken.
5/ Price is a Number custom field. I enter the price as 35.000 (thirty five thousand), does the "." cause issues?
6/ Kilometerstand (mileage) From (minimum) always shows 1 item hidden link even if there are 2 cars with at least 2500km for example.
7/ Kilometerstand (mileage) To (maximum) always shows 0 items hidden link even if there are 2 cars with max 1000km for example.
8/ I have switched to AJAX with submit and added submit button. I now notice that when I select a minimum value for either price or mileage, to maximum value dropdown is immediately reduced to the largest value possible, there are no other choices left.

We just need AJAX filtering on price, mileage and build year where you select a minimum value and the results are filtered, just like here hidden link

#2349429

Please provide a copy of your website in below private message box, you can put the package files in your own google drive disk, share the link only, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/

#2350409

Thanks for the details, I am downloading the files, will update here if find anything

#2351501

I can see the problem when using multiple range filters, and I am checking if it there is any workaround with custom codes, will update here if find anything

#2356875

Sorry for the delay answer, I have to download the new version of duplicator package from your website, and am testing it in my localhost.

#2356881

I have done below modifications in your website:
Edit the post view "Voertuigen Filter":
hidden link
In section "Query Filter":
change the last filter as below:
Prijs is a string between URL_PARAM(wpv-wpcf-prijs_min), URL_PARAM(wpv-wpcf-prijs_max)

Test it in frontend, for example:
hidden link

It works fine, please check if it is fixed, thanks

#2359687
Filter-Used cars.jpg
Filter-New cars.jpg

Thank you, I see that the filtering works.
However, as I have a duplicate of that filter (to only show the new cars), I don't see how I can make the same changes you did on the original filter.
I see "Filter based on the frontend search filter by Prijs." without any chance to edit that.