From f826c4bf5532d4c0467534de4b2607abdb992bfe Mon Sep 17 00:00:00 2001 From: "Jorge A. Torres" Date: Thu, 22 Sep 2022 19:00:20 -0300 Subject: [PATCH] [COT] Restore refund removal functionality when COT is active (#34785) Change `get_post_type()` call in refund removal code to use COT APIs --- plugins/woocommerce/changelog/fix-34222 | 4 ++++ plugins/woocommerce/includes/class-wc-ajax.php | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 plugins/woocommerce/changelog/fix-34222 diff --git a/plugins/woocommerce/changelog/fix-34222 b/plugins/woocommerce/changelog/fix-34222 new file mode 100644 index 00000000000..abd7f5d48af --- /dev/null +++ b/plugins/woocommerce/changelog/fix-34222 @@ -0,0 +1,4 @@ +Significance: minor +Type: fix + +Fix order refund removal when the HPOS datastore is in use. diff --git a/plugins/woocommerce/includes/class-wc-ajax.php b/plugins/woocommerce/includes/class-wc-ajax.php index 17a8ef74d59..e98e48d3048 100644 --- a/plugins/woocommerce/includes/class-wc-ajax.php +++ b/plugins/woocommerce/includes/class-wc-ajax.php @@ -11,6 +11,7 @@ use Automattic\WooCommerce\Internal\Orders\CouponsController; use Automattic\WooCommerce\Internal\Orders\TaxesController; use Automattic\WooCommerce\Internal\Admin\Orders\MetaBoxes\CustomMetaBox; use Automattic\WooCommerce\Utilities\NumberUtil; +use Automattic\WooCommerce\Utilities\OrderUtil; defined( 'ABSPATH' ) || exit; @@ -1959,7 +1960,7 @@ class WC_AJAX { $refund_ids = array_map( 'absint', is_array( $_POST['refund_id'] ) ? wp_unslash( $_POST['refund_id'] ) : array( wp_unslash( $_POST['refund_id'] ) ) ); // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized foreach ( $refund_ids as $refund_id ) { - if ( $refund_id && 'shop_order_refund' === get_post_type( $refund_id ) ) { + if ( $refund_id && 'shop_order_refund' === OrderUtil::get_order_type( $refund_id ) ) { $refund = wc_get_order( $refund_id ); $order_id = $refund->get_parent_id(); $refund->delete( true );