diff --git a/plugins/woocommerce-blocks/src/Templates/CartTemplate.php b/plugins/woocommerce-blocks/src/Templates/CartTemplate.php index 03ea68ecab0..af804d10113 100644 --- a/plugins/woocommerce-blocks/src/Templates/CartTemplate.php +++ b/plugins/woocommerce-blocks/src/Templates/CartTemplate.php @@ -33,7 +33,7 @@ class CartTemplate extends AbstractPageTemplate { */ protected function is_active_template() { global $post; - return get_option( 'woocommerce_cart_page_endpoint' ) === $post->post_name; + return $post instanceof \WP_Post && get_option( 'woocommerce_cart_page_endpoint' ) === $post->post_name; } /** diff --git a/plugins/woocommerce-blocks/src/Templates/CheckoutTemplate.php b/plugins/woocommerce-blocks/src/Templates/CheckoutTemplate.php index 399580012c9..c69df17f9c4 100644 --- a/plugins/woocommerce-blocks/src/Templates/CheckoutTemplate.php +++ b/plugins/woocommerce-blocks/src/Templates/CheckoutTemplate.php @@ -42,6 +42,6 @@ class CheckoutTemplate extends AbstractPageTemplate { */ public function is_active_template() { global $post; - return get_option( 'woocommerce_checkout_page_endpoint' ) === $post->post_name; + return $post instanceof \WP_Post && get_option( 'woocommerce_checkout_page_endpoint' ) === $post->post_name; } }