3

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?

2 Answers 2

5

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).

5
  • I tried this on a fresh installment but it does not work for cheque payments. Only for bacs...
    – fredrik
    Apr 12, 2019 at 17:28
  • @fredrik I have updated my answer code… The hook exists on Github Woocommerce 3.5.7 … but on all installed versions 3.5.7 the hook is missing. Apr 12, 2019 at 17:54
  • @fredrik As this will be on next release, you could edit and make the change on the related core file… Apr 12, 2019 at 18:24
  • 2
    You are correct Loic. I did not ever think of that! Hopefully the new version will be released soon!
    – fredrik
    Apr 12, 2019 at 18:53
  • 1
    This worked perfectly and was just what I needed - big thanks!!!! Oct 3, 2019 at 17:22
0

You're almost there. Right now you are adding a filter for the BACS hook. There is a similar hook for Cheque payment method.

Simply add the following code:

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

It does the exact same, but just for the Cheque orders.

2
  • I tried that, but it does not work for cheque orders! I don't know why, I had found this filter as well but it does not work...
    – fredrik
    Apr 12, 2019 at 17:29
  • @fredrik Try to disable all plugins except woocommerce and then use the 2019 theme. Or try to decrease or increase the priority which is 10 in my example. Try to set it to 1 and to 99
    – Orlandster
    Apr 12, 2019 at 17:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.