Skip to content

Commit

Permalink
Add protective checks around order to prevent issues when order is dr…
Browse files Browse the repository at this point in the history
…afted.
  • Loading branch information
vedanshujain committed Apr 8, 2020
1 parent 9bef7b8 commit e573390
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions includes/tracks/events/class-wc-order-tracking.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ public function init() {
/**
* 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(),
);

Expand Down

0 comments on commit e573390

Please sign in to comment.