How to Disable WooCommerce’s Product Redirect after a Single Search Result

WooCommerce comes out of the box with plenty of little “quality of life” interface improvements and adjustments for your visitors. These tweaks are meant to give customers the quickest route from browsing products, to adding them to their cart and checking out.

One of these improvements is how WooCommerce handles searches that return only one result. When there is only one product that matches a search query the user is not presented the search results screen at all. Instead they are taken directly to the only product that matches what they were looking for.

For example, let’s say you only have one pair of sunglasses for sale on your store. If a user searches for “sunglasses” in your site’s search box they will be redirected straight to the Sunglasses product page.

The intention is to make your potential buyer have to take one less click than necessary to get to the product they want. But what if you don’t want that redirec to take place? Maybe your search results page has shown, through your analytics, that people who visit tend to buy more than one product. In that case, you would want the people doing searches to see the results screen no matter what.

You can disable this single search result redirect with a few lines of code that you will need to add to your WooCommerce theme by yourself. Or you can check out our Remove WooCommerce Features plugin and have it do the work for you.

How to Remove WooCommerce’s Single Search Result Redirect with Code

You can remove this search redirect capability from WooCommerce by adding the following code to your theme’s functions.php file.

add_filter( 'woocommerce_redirect_single_search_result', 'my_remove_search_redirect', 10 );
function my_remove_search_redirect() {
    return false;
}

The functions.php you want is located in your theme’s directory. If you aren’t familiar with the process of editing and uploading theme files, or how to do this properly through a child theme, then you might want to consider reaching out to a WordPress developer and have them assist you. The cost for taking care of this on your site shouldn’t be too outrageous but just make sure they do it in such a way that you don’t need to be constantly re-applying the code after every theme update you do.

How to Disable the Single Product Search Result Redirect with Our Plugin

Remove WooCommerce Features has support for disabling this search redirect function built-in. There’s no need to edit files, insert code or pay a developer to do the work for you. After you’ve purchased and installed the plugin you can turn this off in a moments by following these steps.

Step #1

Go to the WooCommerce section of your WordPress installation’s admin menu and click the link that says “Remove Features.”

WooCommerce Admin Menu

Step #2

Find the setting for “Redirect to Product on Single Search Result” and click the checkbox so that it’s marked like so:

Remove WooCommerce Features - Product Search Redirect on Single Result

Step #3

Press the “Save Settings” button.

Save Settings Button

As soon as you press Save the change will go into effect. The beauty of using Remove WooCommerce Features to handle this, as opposed to making changes to your theme’s code, is that the change will last regardless of any theme updates or changes you make to your site going forward. The plugin remembers your setting and applies it as long as you have Remove WooCommerce Features installed and activated on your site.

Our plugin does a whole lot more than just turn off this default search redirect. You can use it to remove or disable over 20 WooCommerce features without having to write or manage any code yourself. You can use the plugin to:

There is a comprehensive list of all the features the plugin works with here on our site if you’d like to see everything Remove WooCommerce Features can do for you.