Commit 7b13ef34fa4 for woocommerce

commit 7b13ef34fa4706936e00af7ebea91bec6195e3ab
Author: Jorge A. Torres <jorge.torres@automattic.com>
Date:   Wed Apr 8 09:03:45 2026 +0100

    Prevent `is_checkout()` and `is_cart()` from possibly caching invalid values (#63966)

diff --git a/plugins/woocommerce/changelog/fix-62538 b/plugins/woocommerce/changelog/fix-62538
new file mode 100644
index 00000000000..a34c9e3d790
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-62538
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Fix is_checkout/is_cart cache poisoning causing 404 on checkout endpoints when called before main query is ready
diff --git a/plugins/woocommerce/src/Blocks/Utils/CartCheckoutUtils.php b/plugins/woocommerce/src/Blocks/Utils/CartCheckoutUtils.php
index caeaa94b1dd..c8f14db8dba 100644
--- a/plugins/woocommerce/src/Blocks/Utils/CartCheckoutUtils.php
+++ b/plugins/woocommerce/src/Blocks/Utils/CartCheckoutUtils.php
@@ -27,13 +27,13 @@ class CartCheckoutUtils {
 	 * This is determined by looking at the global $post object and comparing it to the post ID defined in settings,
 	 * or checking the page contents for a block or shortcode.
 	 *
-	 * This function cannot be used accurately before the `pre_get_posts` action has been run.
+	 * This function cannot be used accurately before the `wp` action has been run.
 	 *
 	 * @param string $page_type The page type to check for.
 	 * @return bool|null
 	 */
 	private static function is_page_type( string $page_type ): ?bool {
-		if ( ! did_action( 'pre_get_posts' ) ) {
+		if ( ! did_action( 'wp' ) ) {
 			return null;
 		}