Please help figure it out. Some strange behavior in the payment process. If the buyer makes a purchase without using the coupon code, if the payment is successful, it is immediately transferred to the status: completed(it's important). But as soon as the buyer makes a purchase using the coupon. Even with successful payment, the order is transferred to the status: Processing.
I tried to use this code:
add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_complete_paid_order', 20 );
function custom_woocommerce_auto_complete_paid_order( $order_id ) {
if ( ! $order_id )
return;
$order = new WC_Order( $order_id );
if ( $order->has_status( 'processing' ) ) {
$order->update_status( 'completed' );
}else {
return;
}
}
But it doesn't work. Anyway, when paying for an item using a coupon, it first gets into the status Processing. Please, help me figure it out.