Add protective checks around order to prevent issues when order is drafted.

This commit is contained in:
vedanshujain 2020-04-08 09:56:18 +00:00
parent 9bef7b8d63
commit e573390356
1 changed files with 5 additions and 2 deletions

View File

@ -22,12 +22,15 @@ class WC_Order_Tracking {
/**
* Send a Tracks event when an order is viewed.
*
* @param object $order Order.
* @param WC_Order $order Order.
*/
public function track_order_viewed( $order ) {
if ( ! $order->get_id() ) {
return;
}
$properties = array(
'current_status' => $order->get_status(),
'date_created' => $order->get_date_created()->format( DateTime::ATOM ),
'date_created' => $order->get_date_created() ? $order->get_date_created()->format( DateTime::ATOM ) : '',
'payment_method' => $order->get_payment_method(),
);