From 3c9d69c4c07eb6ba605ad9228697c90d805ebf80 Mon Sep 17 00:00:00 2001 From: Evan Herman Date: Thu, 18 Sep 2025 13:43:43 -0400 Subject: [PATCH 1/3] Fix WooCommerce fatal error when using default permalinks --- includes/woocommerce.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/includes/woocommerce.php b/includes/woocommerce.php index 947d6d3f..a5339429 100644 --- a/includes/woocommerce.php +++ b/includes/woocommerce.php @@ -340,6 +340,13 @@ function empty_cart_message() { */ function disable_cart() { + // Skip for API requests. + if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { + + return; + + } + /** * Filter whether to always show the cart icon. * Default: `false` @@ -352,7 +359,7 @@ function disable_cart() { global $woocommerce; - if ( is_admin() || $always_show_cart || 0 < $woocommerce->cart->get_cart_contents_count() ) { + if ( is_admin() || $always_show_cart || ( $woocommerce->cart && 0 < $woocommerce->cart->get_cart_contents_count() ) ) { return; From 2d83a1b68d2a278674ee3e19741338cdc58843ea Mon Sep 17 00:00:00 2001 From: Evan Herman Date: Thu, 18 Sep 2025 13:46:55 -0400 Subject: [PATCH 2/3] Remove REST API check --- includes/woocommerce.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/includes/woocommerce.php b/includes/woocommerce.php index a5339429..fb22aef3 100644 --- a/includes/woocommerce.php +++ b/includes/woocommerce.php @@ -340,13 +340,6 @@ function empty_cart_message() { */ function disable_cart() { - // Skip for API requests. - if ( defined( 'REST_REQUEST' ) && REST_REQUEST ) { - - return; - - } - /** * Filter whether to always show the cart icon. * Default: `false` From 8f80006b54a880c6af219877a63a196d152542bb Mon Sep 17 00:00:00 2001 From: Evan Herman <85256006+eherman-godaddy@users.noreply.github.com> Date: Thu, 18 Sep 2025 14:32:35 -0400 Subject: [PATCH 3/3] Update includes/woocommerce.php Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- includes/woocommerce.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/woocommerce.php b/includes/woocommerce.php index fb22aef3..9985ba75 100644 --- a/includes/woocommerce.php +++ b/includes/woocommerce.php @@ -352,8 +352,9 @@ function disable_cart() { global $woocommerce; - if ( is_admin() || $always_show_cart || ( $woocommerce->cart && 0 < $woocommerce->cart->get_cart_contents_count() ) ) { + $cart = isset( $woocommerce->cart ) ? $woocommerce->cart : null; + if ( is_admin() || $always_show_cart || ( $cart && 0 < $cart->get_cart_contents_count() ) ) { return; }