Commit c2eb100a28 for woocommerce
commit c2eb100a2884950a5d6339e5411b6534920c34ac
Author: Albert Juhé Lluveras <contact@albertjuhe.com>
Date: Mon Feb 9 21:34:19 2026 +0100
Fix issue that caused the shop page not to show up in Divi under certain circumstances (#63202)
* Revert "Fix shop page being occasionally blank (#61788)"
This reverts commit 43f59725acada9c479522299905a5b424739b915.
* Add changelog file
diff --git a/plugins/woocommerce/changelog/fix-divi-shop-page b/plugins/woocommerce/changelog/fix-divi-shop-page
new file mode 100644
index 0000000000..ef1c7be016
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-divi-shop-page
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Fix issue that caused the shop page not to show up in Divi under certain circumstances
diff --git a/plugins/woocommerce/includes/class-wc-query.php b/plugins/woocommerce/includes/class-wc-query.php
index 3ee76d0b68..1f67a91aac 100644
--- a/plugins/woocommerce/includes/class-wc-query.php
+++ b/plugins/woocommerce/includes/class-wc-query.php
@@ -333,11 +333,7 @@ class WC_Query {
if ( $this->is_showing_page_on_front( $q ) ) {
// Fix for endpoints on the homepage.
- $current_page_id = absint( $q->get( 'page_id' ) );
- if ( ! $current_page_id ) {
- $current_page_id = get_queried_object_id();
- }
- if ( ! $this->page_on_front_is( $current_page_id ) ) {
+ if ( ! $this->page_on_front_is( $q->get( 'page_id' ) ) ) {
$_query = wp_parse_args( $q->query );
if ( ! empty( $_query ) && array_intersect( array_keys( $_query ), array_keys( $this->get_query_vars() ) ) ) {
$q->is_page = true;
@@ -378,23 +374,7 @@ class WC_Query {
}
// Special check for shops with the PRODUCT POST TYPE ARCHIVE on front.
- $shop_id = wc_get_page_id( 'shop' );
- $page_id = absint( $q->get( 'page_id' ) );
-
- // Fallback 1: Check queried object ID if page_id not set.
- if ( ! $page_id ) {
- $page_id = get_queried_object_id();
- }
-
- // Fallback 2: Slug comparison when page_id still not resolved.
- if ( ! $page_id && $q->get( 'pagename' ) ) {
- $shop_page = get_post( $shop_id );
- if ( $shop_page && $shop_page->post_name === $q->get( 'pagename' ) ) {
- $page_id = $shop_id;
- }
- }
-
- if ( wc_current_theme_supports_woocommerce_or_fse() && $q->is_page() && 'page' === get_option( 'show_on_front' ) && $page_id === $shop_id ) {
+ if ( wc_current_theme_supports_woocommerce_or_fse() && $q->is_page() && 'page' === get_option( 'show_on_front' ) && absint( $q->get( 'page_id' ) ) === wc_get_page_id( 'shop' ) ) {
// This is a front-page shop.
$q->set( 'post_type', 'product' );
$q->set( 'page_id', '' );
diff --git a/plugins/woocommerce/tests/php/includes/class-wc-query-test.php b/plugins/woocommerce/tests/php/includes/class-wc-query-test.php
index a524cbc82d..abb06816aa 100644
--- a/plugins/woocommerce/tests/php/includes/class-wc-query-test.php
+++ b/plugins/woocommerce/tests/php/includes/class-wc-query-test.php
@@ -77,51 +77,4 @@ class WC_Query_Test extends \WC_Unit_Test_Case {
update_option( 'page_on_front', $default_page_on_front );
wp_delete_post( $shop_page_id, true );
}
-
- /**
- * @testdox Shop page can be identified by slug when page_id is not populated in query vars.
- */
- public function test_shop_page_resolves_by_slug_without_page_id() {
- switch_theme( 'twentytwentyfour' );
-
- $shop_page_id = wp_insert_post(
- array(
- 'post_type' => 'page',
- 'post_status' => 'publish',
- 'post_title' => 'Shop',
- 'post_name' => 'shop',
- )
- );
- $default_woocommerce_shop_page_id = get_option( 'woocommerce_shop_page_id' );
- update_option( 'woocommerce_shop_page_id', $shop_page_id );
-
- // Set the Shop page as the homepage.
- $default_show_on_front = get_option( 'show_on_front' );
- $default_page_on_front = get_option( 'page_on_front' );
- update_option( 'show_on_front', 'page' );
- update_option( 'page_on_front', $shop_page_id );
-
- $query = new WP_Query(
- array(
- 'post_type' => 'page',
- 'pagename' => 'shop',
- // NOTE: We are deliberately NOT setting `page_id` to simulate slug-based resolution.
- // See https://github.com/woocommerce/woocommerce/issues/61676 for more details.
- )
- );
-
- global $wp_the_query;
- $previous_wp_the_query = $wp_the_query;
- $wp_the_query = $query; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
- $query->get_posts();
-
- $this->assertTrue( defined( 'SHOP_IS_ON_FRONT' ) && SHOP_IS_ON_FRONT );
-
- // Reset main query, options and delete the page we created.
- $wp_the_query = $previous_wp_the_query; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
- update_option( 'woocommerce_shop_page_id', $default_woocommerce_shop_page_id );
- update_option( 'show_on_front', $default_show_on_front );
- update_option( 'page_on_front', $default_page_on_front );
- wp_delete_post( $shop_page_id, true );
- }
}