Return early if post status is `auto-draft` to prevent fatal.
While creating an order, if we remove an item after adding, `pre_post_update` hook gets called. Since the order is not created yet, `$order->get_date_created()` will be null, and this will cause a fatal in the event tracker which checks for and tracks edit in order created date. We now return early when order status is `auto-draft` to prevent these kind of errors.
This commit is contained in:
parent
d034131781
commit
6ab03e6acd
|
@ -73,6 +73,10 @@ class WC_Orders_Tracking {
|
|||
return;
|
||||
}
|
||||
|
||||
if ( 'auto-draft' === get_post_status( $id ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$order = wc_get_order( $id );
|
||||
$date_created = $order->get_date_created()->date( 'Y-m-d H:i:s' );
|
||||
// phpcs:disable WordPress.Security.NonceVerification.NoNonceVerification
|
||||
|
|
Loading…
Reference in New Issue