From cd7f429bc14f6f16336b82d8a8d485018e5c2e7d Mon Sep 17 00:00:00 2001 From: Justin Palmer <228780+layoutd@users.noreply.github.com> Date: Mon, 5 Feb 2024 16:06:49 +0100 Subject: [PATCH] Remove Customer Order Count from Order Attribution checkout data (#44359) * Remove Customer Order Count from Checkout Tracks data --- ...-order-attribution-tracks-cust-order-count | 4 +++ .../Orders/OrderAttributionController.php | 30 +++++++++---------- 2 files changed, 18 insertions(+), 16 deletions(-) create mode 100644 plugins/woocommerce/changelog/tweak-remove-order-attribution-tracks-cust-order-count diff --git a/plugins/woocommerce/changelog/tweak-remove-order-attribution-tracks-cust-order-count b/plugins/woocommerce/changelog/tweak-remove-order-attribution-tracks-cust-order-count new file mode 100644 index 00000000000..d78fd3c0e83 --- /dev/null +++ b/plugins/woocommerce/changelog/tweak-remove-order-attribution-tracks-cust-order-count @@ -0,0 +1,4 @@ +Significance: patch +Type: performance + +Remove customer order count from order attribution checkout data. diff --git a/plugins/woocommerce/src/Internal/Orders/OrderAttributionController.php b/plugins/woocommerce/src/Internal/Orders/OrderAttributionController.php index bd9ecb9f7bf..03ee15003f9 100644 --- a/plugins/woocommerce/src/Internal/Orders/OrderAttributionController.php +++ b/plugins/woocommerce/src/Internal/Orders/OrderAttributionController.php @@ -416,27 +416,25 @@ class OrderAttributionController implements RegisterHooksInterface { * @return void */ private function send_order_tracks( array $source_data, WC_Order $order ) { - $origin_label = $this->get_origin_label( + $origin_label = $this->get_origin_label( $source_data['source_type'] ?? '', $source_data['utm_source'] ?? '', false ); - $customer_identifier = $order->get_customer_id() ? $order->get_customer_id() : $order->get_billing_email(); - $customer_info = $this->get_customer_history( $customer_identifier ); - $tracks_data = array( - 'order_id' => $order->get_id(), - 'source_type' => $source_data['source_type'] ?? '', - 'medium' => $source_data['utm_medium'] ?? '', - 'source' => $source_data['utm_source'] ?? '', - 'device_type' => strtolower( $source_data['device_type'] ?? 'unknown' ), - 'origin_label' => strtolower( $origin_label ), - 'session_pages' => $source_data['session_pages'] ?? 0, - 'session_count' => $source_data['session_count'] ?? 0, - 'order_total' => $order->get_total(), - // Add 1 to include the current order (which is currently still Pending when the event is sent). - 'customer_order_count' => $customer_info['order_count'] + 1, - 'customer_registered' => $order->get_customer_id() ? 'yes' : 'no', + + $tracks_data = array( + 'order_id' => $order->get_id(), + 'source_type' => $source_data['source_type'] ?? '', + 'medium' => $source_data['utm_medium'] ?? '', + 'source' => $source_data['utm_source'] ?? '', + 'device_type' => strtolower( $source_data['device_type'] ?? 'unknown' ), + 'origin_label' => strtolower( $origin_label ), + 'session_pages' => $source_data['session_pages'] ?? 0, + 'session_count' => $source_data['session_count'] ?? 0, + 'order_total' => $order->get_total(), + 'customer_registered' => $order->get_customer_id() ? 'yes' : 'no', ); + $this->proxy->call_static( WC_Tracks::class, 'record_event', 'order_attribution', $tracks_data ); }