Track viewing an order
This commit is contained in:
parent
7adabc9a6a
commit
928529880d
|
@ -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 ) {
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue