[COT] Restore refund removal functionality when COT is active (#34785)

Change `get_post_type()` call in refund removal code to use COT APIs
This commit is contained in:
Jorge A. Torres 2022-09-22 19:00:20 -03:00 committed by GitHub
parent 7b55c334ad
commit f826c4bf55
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: fix
Fix order refund removal when the HPOS datastore is in use.

View File

@ -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 );