class-wc-admin-setup-wizard-tracking.php
5 years ago
class-wc-coupon-tracking.php
6 years ago
class-wc-coupons-tracking.php
7 months ago
class-wc-extensions-tracking.php
1 year ago
class-wc-importer-tracking.php
3 years ago
class-wc-order-tracking.php
6 years ago
class-wc-orders-tracking.php
1 year ago
class-wc-product-collection-block-tracking.php
7 months ago
class-wc-products-tracking.php
1 month ago
class-wc-settings-tracking.php
11 months ago
class-wc-status-tracking.php
7 months ago
class-wc-theme-tracking.php
1 year ago
class-wc-order-tracking.php
41 lines
| 1 | <?php |
| 2 | /** |
| 3 | * WooCommerce Order Tracking |
| 4 | * |
| 5 | * @package WooCommerce\Tracks |
| 6 | */ |
| 7 | |
| 8 | defined( 'ABSPATH' ) || exit; |
| 9 | |
| 10 | /** |
| 11 | * This class adds actions to track usage of a WooCommerce Order. |
| 12 | */ |
| 13 | class WC_Order_Tracking { |
| 14 | |
| 15 | /** |
| 16 | * Init tracking. |
| 17 | */ |
| 18 | public function init() { |
| 19 | add_action( 'woocommerce_admin_order_data_after_order_details', array( $this, 'track_order_viewed' ) ); |
| 20 | } |
| 21 | |
| 22 | /** |
| 23 | * Send a Tracks event when an order is viewed. |
| 24 | * |
| 25 | * @param WC_Order $order Order. |
| 26 | */ |
| 27 | public function track_order_viewed( $order ) { |
| 28 | if ( ! $order instanceof WC_Order || ! $order->get_id() ) { |
| 29 | return; |
| 30 | } |
| 31 | $properties = array( |
| 32 | 'current_status' => $order->get_status(), |
| 33 | 'date_created' => $order->get_date_created() ? $order->get_date_created()->format( DateTime::ATOM ) : '', |
| 34 | 'payment_method' => $order->get_payment_method(), |
| 35 | ); |
| 36 | |
| 37 | WC_Tracks::record_event( 'single_order_view', $properties ); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 |