Forums Forums Search & Filter Pro Prices – change ranges to custom

Tagged: 

Viewing 5 posts - 21 through 25 (of 25 total)
  • Anonymous
    #257781
    This reply has been marked as private.
    Ross Moderator
    #258072
    This reply has been marked as private.
    Anonymous
    #258377
    This reply has been marked as private.
    Ross Moderator
    #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

    Anonymous
    #275765
    This reply has been marked as private.
Viewing 5 posts - 21 through 25 (of 25 total)