Forums › Forums › Search & Filter Pro › Number Ranges Min-Max values
Tagged: V3
- This topic has 14 replies, 2 voices, and was last updated 4 years, 3 months ago by Trevor.
-
Anonymous(Private) September 1, 2020 at 8:42 am #257902
Hello, I am opening a separate thread because I think this requires special attention.
In all number ranges, either single or from/to fields the following options should be available:
– Custom sets of values… eg define your own min/max values that are step independent. Imagine the following scenario:
Min/Max
0-500
500-1000
1000-5000
5000-50000
50000-100000
etc– On top of this feature, it would be a good idea to be able to have a checkbox of some sort that does not restrict you to either a min or a max value. Based on the example I set previously.
Min/Max
…
50000-100000
100000+ (No max)NS
Trevor(Private) September 1, 2020 at 4:39 pm #257981This will come in V3, but you do it now using one of our filters:
https://searchandfilter.com/documentation/action-filter-reference/#filter-input-object
This post from our developer, Ross, has an example:
https://support.searchandfilter.com/forums/topic/prices-change-ranges-to-custom/page/2/#post-257605
Anonymous(Private) September 2, 2020 at 2:09 pm #258119So, here is my code, don’t know how you want to make use for it, but here it is in case it helps someone!
First of all, I just set a couple of values in the admin, 0-100 – it makes no difference since I am unsetting the initial options anyway:
function change_car_engine_size($input_object, $sfid) { if($input_object['name']=='_sfm_car_engine_size') { unset($input_object['options']); $input_object['options']=array(); $arr = ['0','100','200','300','400', '500', '600', '700', '800', '900', '1000','2500','3000','3500','4000']; foreach ($arr as $value) { $new_option = new StdClass(); $new_option->value = $value; $new_option->label = number_format($value, 0, ',', '.'); array_push($input_object['options'], $new_option); } } return $input_object; } add_filter('sf_input_object_pre', 'change_car_engine_size', 10, 2);
-
AuthorPosts