Forums › Forums › Search & Filter Pro › Number Ranges Min-Max values
Tagged: V3
- This topic has 14 replies, 2 voices, and was last updated 5 years ago by
Trevor.
-
Trevor(Private) September 1, 2020 at 4:39 pm #257981
This 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);
Anonymous(Private) September 2, 2020 at 2:41 pm #258142Sorry for bashing on the post…
just a slight improvement of the code would be in this particular case. If no selection is made, then use these values.
if (!isset($_GET['_sfm_car_engine_size'])) { $input_object['default_max']=500000; $input_object['default_max_formatted']=500000; }
-
AuthorPosts