woocommerce_redirect_single_search_resultfilter-hookWC 1.0

Allows you to disable redirection from the WooCommerce search results page to the product page when it is the only search result.

Usage

add_filter( 'woocommerce_redirect_single_search_result', 'wp_kama_woocommerce_redirect_single_search_result_filter' );

/**
 * Function for `woocommerce_redirect_single_search_result` filter-hook.
 * 
 * @param  $true 
 *
 * @return 
 */
function wp_kama_woocommerce_redirect_single_search_result_filter( $true ){
	// filter...
	return $true;
}
$true(boolean)
true - redirect, false - do not redirect.
Default: true

Examples

#1 Disable the redirect

This simple hook disables redirection to a WooCommerce product page when only one product is found in the search results.

add_filter( 'woocommerce_redirect_single_search_result', '__return_false' );

Where the hook is called

wc_template_redirect()
woocommerce_redirect_single_search_result
woocommerce/includes/wc-template-functions.php 75
if ( is_search() && is_post_type_archive( 'product' ) && apply_filters( 'woocommerce_redirect_single_search_result', true ) && 1 === absint( $wp_query->found_posts ) ) {

Where the hook is used in WooCommerce

Usage not found.