Skip Navigation

[Resolved] How to setup price range

This support ticket is created 5 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 1 reply, has 2 voices.

Last updated by Luo Yang 5 years, 7 months ago.

Assisted by: Luo Yang.

Author
Posts
#1243218
Price-Range2.png
Price-Range.png

Tell us what you are trying to do?
I need to set up 4 price range in custom search fields:
- All
- up to 90
- from 91 to 120
- above 121

At the moment I set it in filters like that:
- nothing; All
- <90; to 90
- >91 =<120; between 91 and 120
- >121; above 121

Only "- nothing; All" works, how should I set other 3 values?
I am sending you 2 screens

Is there any documentation that you are following?
https://toolset.com/documentation/user-guides/filtering-views-by-custom-fields/

What is the link to your site?
hidden link

#1243352

Hello,

Your screenshot isn't in English, that did not help much.

I assume we are talking about a custom numeric field, and you are going to add a selector range filter on this custom field.

If it is, it needs custom codes, for example, you can setup the selector "price-range" option values as below:
- All: 0 - 999999
- up to 90: 0-90
- from 91 to 120: 90-120
- above 121: 121-999999

Then use Views filter hook wpv_filter_query to trigger a PHP function, in this PHP function:
1) get the URL parameter value of "price-range",
2) explode the value to an array using separator "-"
3) Apply above array value into View's field query

More help:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query
When displaying a View listing posts, this filter is applied to the arguments being generated by the View settings before they are passed to the WP_Query class.
https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters
compare (string) - ... 'BETWEEN',