Forums › Forums › Search & Filter Pro › Prices – change ranges to custom
Tagged: V3
- This topic has 24 replies, 3 voices, and was last updated 4 years ago by
Anonymous.
-
Ross Moderator(Private) September 2, 2020 at 9:14 am #258072This reply has been marked as private.Ross Moderator(Private) September 8, 2020 at 5:58 pm #258820
I don’t have access to your site anymore, but this will replace all the optinos, with the 3 options you asked for:
function update_field_options($input_object, $sfid){ if( $input_object['name'] != '_sfm__price' ) { return $input_object; } // if we want to filter the options generated, we need to make sure the options variable actually exists before proceeding (its only available to certain field types) if( ! isset( $input_object['options'] ) ) { return $input_object; } // this is an array of all the options, we can remove them all, recreate them, etc $new_options = array(); // so create 3 options: $option1 = new StdClass(); $option1->value = "0+100"; $option1->label = "0 - 100"; array_push( $new_options, $option1 ); $option2 = new StdClass(); $option2->value = "100+250"; $option2->label = "100 - 250"; array_push( $new_options, $option2 ); $option3 = new StdClass(); $option3->value = "250+10000000"; $option3->label = "250 kr and up"; array_push( $new_options, $option3 ); $input_object['options'] = $new_options; return $input_object; } add_filter('sf_input_object_pre', 'update_field_options', 10, 2);
Thanks
-
AuthorPosts