Track viewing an order

This commit is contained in:
Rebecca Scott 2020-03-18 13:14:31 +10:00
parent 7adabc9a6a
commit 928529880d
2 changed files with 39 additions and 0 deletions

View File

@ -113,6 +113,7 @@ class WC_Site_Tracking {
include_once WC_ABSPATH . 'includes/tracks/events/class-wc-settings-tracking.php';
include_once WC_ABSPATH . 'includes/tracks/events/class-wc-status-tracking.php';
include_once WC_ABSPATH . 'includes/tracks/events/class-wc-coupons-tracking.php';
include_once WC_ABSPATH . 'includes/tracks/events/class-wc-order-tracking.php';
$tracking_classes = array(
'WC_Admin_Setup_Wizard_Tracking',
@ -123,6 +124,7 @@ class WC_Site_Tracking {
'WC_Settings_Tracking',
'WC_Status_Tracking',
'WC_Coupons_Tracking',
'WC_Order_Tracking',
);
foreach ( $tracking_classes as $tracking_class ) {

View File

@ -0,0 +1,37 @@
<?php
/**
* WooCommerce Order Tracking
*
* @package WooCommerce\Tracks
*/
defined( 'ABSPATH' ) || exit;
/**
* This class adds actions to track usage of a WooCommerce Order.
*/
class WC_Order_Tracking {
/**
* Init tracking.
*/
public function init() {
add_action( 'woocommerce_admin_order_data_after_order_details', array( $this, 'track_order_viewed' ) );
}
/**
* Send a Tracks event when an order is viewed.
*
* @param object $order Order.
*/
public function track_order_viewed( $order ) {
$properties = array(
'order_id' => $order->get_id(),
'current_status' => $order->get_status(),
'date_created' => $order->get_date_created(),
'payment_method' => $order->get_payment_method(),
);
WC_Tracks::record_event( 'wcadmin_single_order_view', $properties );
}
}