Remove Customer Order Count from Order Attribution checkout data (#44359)

* Remove Customer Order Count from Checkout Tracks data
This commit is contained in:
Justin Palmer 2024-02-05 16:06:49 +01:00 committed by GitHub
parent a943de24fa
commit cd7f429bc1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 16 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: performance
Remove customer order count from order attribution checkout data.

View File

@ -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 );
}