Ensure product exists before is_visible check

Closes #7146
This commit is contained in:
Mike Jolley 2015-01-19 10:43:43 +00:00
parent bbfe9f273b
commit 53f32416c5
1 changed files with 1 additions and 1 deletions

View File

@ -44,7 +44,7 @@ function wc_template_redirect() {
elseif ( is_search() && is_post_type_archive( 'product' ) && apply_filters( 'woocommerce_redirect_single_search_result', true ) && $wp_query->found_posts == 1 ) {
$product = wc_get_product( $wp_query->post );
if ( $product->is_visible() ) {
if ( $product && $product->is_visible() ) {
wp_safe_redirect( get_permalink( $product->id ), 302 );
exit;
}