• Resolved nimra98

    (@nimra98)


    I want to use it to look for some woocommerce products whose main name is text with a number:
    So I have some products names like these ones:
    – product tilt 750
    – product speed 500
    – product tilt 150
    I want to get just one result if someone searchs just for the character “750” (the first in this example) and not getting the same product in all cases… is it possible?

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @nimra98

    You can limit autocomplete results to one in WooCommerce -> FiboSearch -> Autocomplete (tab). So only one result will be visible in the dropdown.

    To make sure that the correct product will appear in search results you can add an extra score to products that will contain the search phrase in the title.

    add_filter( 'dgwt/wcas/search_results/product/score', function ( $score, $keyword, $post ) {	
    	$product_title = get_the_title( $post );
    		
    	if ( strstr( $product_title, $keyword ) !== false ) {
    		$score += 500;
    	}
    			
        return $score;
    }, 10, 3 );

    You have two ways to add this code to your theme:
    Open the functions.php in your child theme and add the code at the end.
    or install the Code Snippets plugin and apply this code as a snippet.

    Then if only one result will be visible, the native WooCommerce function will redirect the user to the product page instead of the search results.

    Regards,
    Kris

    Thread Starter nimra98

    (@nimra98)

    Hi Kris (@c0nst),
    I did but not showing relevant number search. I’m tired to solve this issue. Product name is “ADIDAS ADI-STAR SPEED 750 BOXING GLOVES`” when I am searching 750 the result shows me some random product. I want to fix this but how can I?

    check check: https://acs-demo.bmn-es.com/

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Numbers search’ is closed to new replies.