Delete wc order (WIP)

This commit is contained in:
Emili Castells Guasch 2025-04-25 18:07:07 +02:00
parent f42d87bb29
commit 52763fc67e
No known key found for this signature in database
3 changed files with 11 additions and 14 deletions

View file

@ -188,18 +188,6 @@ class CardFieldsModule implements ServiceModule, ExtendingModule, ExecutableModu
$logger->warning( "Could not capture order {$order->id()}" );
// Deletes WC order if it exists in PayPal order.
$wc_order_id = (int)$order->purchase_units()[0]->custom_id();
if( $wc_order_id ) {
$wc_order = wc_get_order( $wc_order_id );
if ( $wc_order instanceof WC_Order ) {
$result = $this->is_hpos_enabled() ? $wc_order->delete(true) : wp_delete_post($wc_order_id, true);
if($result) {
$logger->info( "Deleting failed WC order #$wc_order_id" );
}
}
}
throw new DomainException( esc_html__( 'Could not capture the PayPal order.', 'woocommerce-paypal-payments' ) );
}
}