From 14577857e75f6cdb778115e414830b7398627e80 Mon Sep 17 00:00:00 2001 From: Boro Sitnikovski Date: Thu, 19 Dec 2024 13:09:26 +0100 Subject: [PATCH] Add similar check to class-universal --- .../packages/woocommerce-analytics/src/class-universal.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/projects/packages/woocommerce-analytics/src/class-universal.php b/projects/packages/woocommerce-analytics/src/class-universal.php index 03f8a7548660b..511fe3b8f20e9 100644 --- a/projects/packages/woocommerce-analytics/src/class-universal.php +++ b/projects/packages/woocommerce-analytics/src/class-universal.php @@ -9,6 +9,7 @@ use WC_Order; use WC_Product; +use WP_Post; /** * Filters and Actions added to Store pages to perform analytics @@ -209,6 +210,12 @@ public function get_shipping_option_for_item( $cart_item_key ) { * On the Checkout page, trigger an event for each product in the cart */ public function checkout_process() { + global $post; + + if ( ! $post instanceof WP_Post ) { + return; + } + $checkout_page_id = wc_get_page_id( 'checkout' ); $cart = WC()->cart->get_cart(); $is_in_checkout_page = $checkout_page_id && is_page( $checkout_page_id ) ? 'Yes' : 'No';