Home » WooCommerce: Disable Single Search Result Redirect

WooCommerce: Disable Single Search Result Redirect

by adminkys

You have a WooCommerce product called “VREIUTERTKXYU“. You search for “VREIUTERTKXYU” (exact match). WooCommerce, by default, redirects you to the single product page as there is only 1 possible search result (as opposed to sending you to the search result page).

In today’s tutorial, we will be deactivating this WooCommerce function and go back to the normal (at least, to me) behavior: even if there is an exact match in a search (single search result), we still want to display the search page.

The screenshot that follows gives you a working proof, once the snippet you find below is active. Enjoy!

Without the PHP customization below, this search query would have taken me directly to the relevant WooCommerce single product page as opposed to showing me the search result page with a single result.

PHP Snippet: Disable Redirect For Single Search Results @ WooCommerce Search

/**
 * @snippet       Disable Single Search Result Redirect | WooCommerce
 * @how-to        Get tutoraspire.com FREE
 * @author        Tutor Aspire
 * @compatible    WooCommerce 6
 * @donate $9     https://www.tutoraspire.com
 */

add_filter( 'woocommerce_redirect_single_search_result', '__return_false' );

You may also like