Fire 'woocommerce_process_shop_order_meta' only once when updating orders on the admin (#39587)

This commit is contained in:
Barry Hughes 2023-08-04 15:41:29 -07:00 committed by GitHub
commit c4f00719de
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: tweak
Do not run 'woocommerce_process_shop_order_meta' for order post when HPOS is authoritative.

View File

@ -9,6 +9,7 @@
use Automattic\Jetpack\Constants;
use Automattic\WooCommerce\Internal\Admin\Orders\Edit as OrderEdit;
use Automattic\WooCommerce\Utilities\OrderUtil;
defined( 'ABSPATH' ) || exit;
@ -215,7 +216,7 @@ class WC_Admin_Meta_Boxes {
$post_id = absint( $post_id );
// $post_id and $post are required
if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) {
if ( empty( $post_id ) || empty( $post ) || ! is_a( $post, 'WP_Post' ) || self::$saved_meta_boxes ) {
return;
}
@ -247,6 +248,10 @@ class WC_Admin_Meta_Boxes {
// Check the post type.
if ( in_array( $post->post_type, wc_get_order_types( 'order-meta-boxes' ), true ) ) {
if ( OrderUtil::custom_orders_table_usage_is_enabled() ) {
return;
}
/**
* Save meta for shop order.
*