Skip to content
Advertisement

Change default WooCommerce order status to processing for cheque and bacs payments

In WooCommerce, I need all my orders to go immediately to “processing” status to have the order-processing email sent directly when the order is processed.

By default, this behavior exist for Paypal and COD orders, but not for BACS and Cheque where the default status is on-hold.

I tried several snippets like this one:

add_action( 'woocommerce_thankyou', 'custom_woocommerce_auto_process_order' );

function custom_woocommerce_auto_process_order( $order_id ) { 
    if ( ! $order_id ) {
       return;
    }

    $order = wc_get_order( $order_id );
    $order->update_status( 'processing' );
}

But this doesn’t work, the order still shows up in “on-hold” status and the processing email notification is not sent. Now I just found a this snippet:

add_filter( 'woocommerce_bacs_process_payment_order_status', function( $status = 'on_hold', $order = null ) {
    return 'processing';
}, 10, 2 );

And it works, but only for “BACS”. How can I adapt it to also work for “Cheque” orders?

Advertisement

Answer

The filter hook woocommerce_cheque_process_payment_order_status is not yet implemented in Woocommerce 3.5.7 … if you look to the file located in your woocommerce plugin under:
includes > gateways > cheque > class-wc-gateway-cheque.php, the hook is missing (line 122):

$order->update_status( 'on-hold', _x( 'Awaiting check payment', 'Check payment method', 'woocommerce' ) );

But on Github WC version 3.5.7 for class-wc-gateway-cheque.php file, the hook exist (line 122):

$order->update_status( apply_filters( 'woocommerce_cheque_process_payment_order_status', 'on-hold', $order ), _x( 'Awaiting check payment', 'Check payment method', 'woocommerce' ) );

The hook will is planed to be available next WooCommerce 3.6 release, see the file change on Woocommerce Github. It’s tagged 3.6.0-rc.2 and 3.6.0-beta.1

So it will be possible to change the default order status to “processing” for “bacs” and “cheque” payment methods, using the following:

add_filter( 'woocommerce_bacs_process_payment_order_status','filter_process_payment_order_status_callback', 10, 2 );
add_filter( 'woocommerce_cheque_process_payment_order_status','filter_process_payment_order_status_callback', 10, 2 );
function filter_process_payment_order_status_callback( $status, $order ) {
    return 'processing';
}

Code goes in functions.php file of your active child theme (or active theme).

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement