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';