Transitioning HPOS orders from auto-draft should trigger new order hook
This commit is contained in:
parent
4b0416d251
commit
26043fa0ea
|
@ -2339,6 +2339,9 @@ FROM $order_meta_table
|
||||||
* @param \WC_Order $order Order object.
|
* @param \WC_Order $order Order object.
|
||||||
*/
|
*/
|
||||||
public function update( &$order ) {
|
public function update( &$order ) {
|
||||||
|
$previous_status = ArrayUtil::get_value_or_default( $order->get_data(), 'status' );
|
||||||
|
$changes = $order->get_changes();
|
||||||
|
|
||||||
// Before updating, ensure date paid is set if missing.
|
// Before updating, ensure date paid is set if missing.
|
||||||
if (
|
if (
|
||||||
! $order->get_date_paid( 'edit' )
|
! $order->get_date_paid( 'edit' )
|
||||||
|
@ -2372,6 +2375,12 @@ FROM $order_meta_table
|
||||||
$order->apply_changes();
|
$order->apply_changes();
|
||||||
$this->clear_caches( $order );
|
$this->clear_caches( $order );
|
||||||
|
|
||||||
|
// For backwards compatibility, moving an auto-draft order to a valid status triggers the 'woocommerce_new_order' hook.
|
||||||
|
if ( ! empty( $changes['status'] ) && 'auto-draft' === $previous_status ) {
|
||||||
|
do_action( 'woocommerce_new_order', $order->get_id(), $order ); // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
do_action( 'woocommerce_update_order', $order->get_id(), $order ); // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
|
do_action( 'woocommerce_update_order', $order->get_id(), $order ); // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue