Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change orders status made with cheque payment method to "processing" status

I need to make WooCommerce push payments made by check into the "processing" status rather than the "on hold" status. I tried the snippet below however it doesn't seem to have an effect.

Here is my code:

add_filter( 'woocommerce_payment_complete_order_status', 'sf_wc_autocomplete_paid_orders' );

function sf_wc_autocomplete_paid_orders( $order_status, $order_id ) {

$order = wc_get_order( $order_id );

if ($order->status == 'on-hold') {
    return 'processing';
}

return $order_status;
}

How can I achieve this?

Thanks.

like image 807
DarkSpartan47 Avatar asked Dec 02 '25 13:12

DarkSpartan47


1 Answers

Here is the function you are looking at hooked in woocommerce_thankyou hook:

add_action( 'woocommerce_thankyou', 'cheque_payment_method_order_status_to_processing', 10, 1 );
function cheque_payment_method_order_status_to_processing( $order_id ) {
    if ( ! $order_id )
        return;

    $order = wc_get_order( $order_id );

    // Updating order status to processing for orders delivered with Cheque payment methods.
    if ( $order->get_payment_method() === 'cheque' ) {
        $order->update_status( 'processing' );
    }
}

This code goes in function.php file of your active child theme (or theme) or also in any plugin file.

This is tested and works.


Related thread: WooCommerce: Auto complete paid orders

like image 86
LoicTheAztec Avatar answered Dec 05 '25 04:12

LoicTheAztec



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!