From d44e882f5d7adc0152eab1e27f57732ebd807dcb Mon Sep 17 00:00:00 2001 From: Jorge Torres Date: Fri, 11 Aug 2023 14:57:34 -0300 Subject: [PATCH] Trashing/untrashing orders and updating CPT datastore-level props should not trigger update hook --- .../src/Internal/DataStores/Orders/OrdersTableDataStore.php | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/plugins/woocommerce/src/Internal/DataStores/Orders/OrdersTableDataStore.php b/plugins/woocommerce/src/Internal/DataStores/Orders/OrdersTableDataStore.php index 61932d0f815..78b3dc3c552 100644 --- a/plugins/woocommerce/src/Internal/DataStores/Orders/OrdersTableDataStore.php +++ b/plugins/woocommerce/src/Internal/DataStores/Orders/OrdersTableDataStore.php @@ -2381,6 +2381,12 @@ FROM $order_meta_table return; } + // For backwards compat with CPT, trashing/untrashing and changing previously datastore-level props does not trigger the update hook. + if ( ( ! empty( $changes['status'] ) && in_array( 'trash', array( $changes['status'], $previous_status ), true ) ) + || ! array_diff_key( $changes, array_flip( $this->get_post_data_store_for_backfill()->get_internal_data_store_key_getters() ) ) ) { + return; + } + do_action( 'woocommerce_update_order', $order->get_id(), $order ); // phpcs:ignore WooCommerce.Commenting.CommentHooks.MissingHookComment }