Support Forums

The forums are closed and will be removed when we launch our new site.

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro Range Select: Add value at the beginning (text)

Tagged: 

Viewing 3 posts - 11 through 13 (of 13 total)
  • Ross Moderator
    #105123

    Hi Javier

    You can do this with the current version..

    Take a look at the docs here:

    https://www.designsandcode.com/documentation/search-filter-pro/action-filter-reference/#Filter_Input_Object

    Nearly any value in any input object can be changed if you dig deep enough into the $input_object there are all kinds of things that can be changed.

    Tested locally, and updated to match your field name _sfm_precio, this should do the trick:

    function filter_range_dropdown($input_object, $sfid)
    {
    	
    	if($input_object['name']=='_sfm_precio')
    	{
    		//udpate this field before rendering
    		//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;
    		}
    		
    		//now loop through the options in the field
    		foreach($input_object['options'] as $option)
    		{
    			//update every label, and prefix and suffix with $
    			$option->label = "$ ".$option->label." $";
    		}		
    	}
    
    	//always return the input object, even if we made no changes
    	return $input_object;
    }
    add_filter('sf_input_object_pre', 'filter_range_dropdown', 10, 2);

    Hope that helps

    Javier Riveros
    #105196

    That is absolutely fantastic!
    I made a little change in the line that ads the currency symbol to use with euro only at the beginning.

    One las question: With this code in mind … is there a way to add an “initial option” with text: “Price from” and “Price to” ??
    I know I asked before that but just want to be sure.
    Thanks!

    Trevor Moderator
    #105208

    There may well be, the documentation is here, and I think there are other examples linked.

Viewing 3 posts - 11 through 13 (of 13 total)

The forum ‘Search & Filter Pro’ is closed to new topics and replies.