This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Help with Search Variation

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Help with Search Variation

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #6630
    louiepelonlouiepelon
    Participant

    Please take a look at the attached screenshot. I have a tire section to where I would like the search show results no matter how the variation is entered. For example, a tire tire is normally 225/40R18. My title (screenshot) has this variation, BUT I want to be able to search as 2254018 WITHOUT the / and R. How would that be possible? I do not want to alter my title.
    Thank you in advance.

    Luis

    #6632
    Ernest MarcinkoErnest 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):

    [php]
    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;
    }
    [/php]

    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!

    #6633
    louiepelonlouiepelon
    Participant

    This most definitely works! Thank you Ernesto. Fast service and response

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.