diff --git a/woocommerce-core-functions.php b/woocommerce-core-functions.php index ef0b4da3dc8..1c9dee81b04 100644 --- a/woocommerce-core-functions.php +++ b/woocommerce-core-functions.php @@ -24,10 +24,13 @@ function woocommerce_mail( $to, $subject, $message, $headers = "Content-Type: te * WooCommerce page IDs * * retrieve page ids - used for myaccount, edit_address, change_password, shop, cart, checkout, pay, view_order, thanks, terms, order_tracking + * + * returns -1 if no page is found **/ if (!function_exists('woocommerce_get_page_id')) { function woocommerce_get_page_id( $page ) { - return apply_filters('woocommerce_get_' . $page . '_page_id', get_option('woocommerce_' . $page . '_page_id')); + $page = apply_filters('woocommerce_get_' . $page . '_page_id', get_option('woocommerce_' . $page . '_page_id')); + return ($page) ? $page : -1; } } diff --git a/woocommerce-functions.php b/woocommerce-functions.php index 83178214d63..70007062970 100644 --- a/woocommerce-functions.php +++ b/woocommerce-functions.php @@ -16,7 +16,7 @@ function woocommerce_redirects() { global $woocommerce; // When default permalinks are enabled, redirect shop page to post type archive url - if ( isset($_GET['page_id']) && get_option( 'permalink_structure' )=="" && $_GET['page_id'] == woocommerce_get_page_id('shop') ) : + if ( isset($_GET['page_id']) && $_GET['page_id'] > 0 && get_option( 'permalink_structure' )=="" && $_GET['page_id'] == woocommerce_get_page_id('shop') ) : wp_safe_redirect( get_post_type_archive_link('product') ); exit; endif;