From 5165a00d60257759c6f1212c428a0743ef73edcc Mon Sep 17 00:00:00 2001 From: rg755421 Date: Mon, 28 Sep 2026 14:10:20 +0545 Subject: [PATCH 1/2] Fix - WC()->cart null check missing on the centre-logo header layout e485518 added `isset( WC()->cart )` to header.php's default cart block, but the theme has a second, near-identical cart block for the center-logo-below-menu layout that was never touched. Any WooCommerce site using that layout still fataled on WC()->cart->get_cart_contents_count() whenever WC()->cart was null (REST requests, other non-frontend renders). Verified with both header.php cart blocks rendered directly, WC()->cart forced null: the unpatched block fatals as expected, the patched one (this commit) doesn't, for both header layouts. See themegrill/flash-pro#83. Co-Authored-By: Claude Sonnet 5 --- header.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/header.php b/header.php index 7dfac20..f17cca4 100644 --- a/header.php +++ b/header.php @@ -125,7 +125,7 @@
- cart ) ) : $cart_url = function_exists( 'wc_get_cart_url' ) ? wc_get_cart_url() : WC()->cart->get_cart_url(); ?> From 0a313f9103ffa77702766b50b9752b19f7fc2b97 Mon Sep 17 00:00:00 2001 From: rg755421 Date: Tue, 29 Sep 2026 18:04:46 +0545 Subject: [PATCH 2/2] Fix - Review: same WC()->cart null fatal in the AJAX cart fragment flash_woocommerce_header_add_to_cart_fragment() (inc/woocommerce.php) has the identical unguarded WC()->cart access this PR fixed elsewhere, and fatals the same way when the cart isn't initialised - confirmed live by forcing WC()->cart null into the woocommerce_add_to_cart_fragments filter. Early-returns the fragments array unchanged when the cart isn't available, same guard condition as the other fix. Co-Authored-By: Claude Sonnet 5 --- inc/woocommerce.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/inc/woocommerce.php b/inc/woocommerce.php index 5a0f2ca..837191a 100644 --- a/inc/woocommerce.php +++ b/inc/woocommerce.php @@ -37,6 +37,10 @@ function flash_wc_wrapper_end() { add_filter( 'woocommerce_add_to_cart_fragments', 'flash_woocommerce_header_add_to_cart_fragment' ); function flash_woocommerce_header_add_to_cart_fragment( $fragments ) { + if ( ! isset( WC()->cart ) ) { + return $fragments; + } + ob_start(); $cart_url = function_exists( 'wc_get_cart_url' ) ? wc_get_cart_url() : WC()->cart->get_cart_url(); ?>