Forums › Forums › Search & Filter Pro › Prices – change ranges to custom
Tagged: V3
- This topic has 24 replies, 3 voices, and was last updated 3 years, 9 months ago by Anonymous.
-
Ross Moderator(Private) August 28, 2020 at 9:32 am #257605
Hi Thomas
I just did a test, this code, replaces the 4 th option in a list, with what you mention:
function update_field_options($input_object, $sfid){ // ensure we are only filtering the correct field name - in this case the field we want to filter has the name '_sft_post_tag' 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 // var_dump( $input_object['options'] ); // we know the option you want to replace is the 4th one in the list (including the default), so we can do : if ( isset ( $input_object['options'][3] ) ) { $new_option = new StdClass(); $new_option->value = "250+10000000"; $new_option->label = "250 kr and up"; $input_object['options'][3] = $new_option; } return $input_object; } add_filter('sf_input_object_pre', 'update_field_options', 10, 2);
That should get you going 🙂
Read the comments for a few clues.
Best
-
AuthorPosts