Merge pull request #26117 from woocommerce/fix/26110
Add protective checks around order to prevent issues when order is drafted
This commit is contained in:
commit
f888908a70
|
@ -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 instanceof WC_Order || ! $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(),
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue