Reply To: Help with Search Variation

#6632

Ernest Marcinko
Keymaster

Hi!

Luckily you don't have to alter your titles. The plugin code has a so called “filter point” before and after the search phrase is processed and sent to the database. This allows to create custom codes to make modifications to the search phrase, without actually changing anything in the plugin code.

I've quickly put together a function, that should help you with this. Put this code to your themes functions.php file (it should be in your active theme directory):

add_filter( 'asp_search_phrase_after_cleaning', 'remove_slash_and_r', 1, 1 );

function remove_slash_and_r( $phrase ) {
    $temp_phrase = str_replace(array("/", "R"), "", $phrase);
    
    if ($temp_phrase != $phrase) 
      $phrase = $phrase . " " . $temp_phrase;
      
    return $phrase;
}

This code replaces “R” or “/” characters in the search phrase, then compares it to the original. If they are different, then it appends the one without the “R” or “/” characters.
Basically if the user types in “225/40R18” the search will register it as “225/40R18 2254018”, so it will search for 2554018 as well.

Let me know how this works!

Best,
Ernest Marcinko

If you like my products, don't forget to rate them on codecanyon :)