使用支票付款方式将订单状态更改为“处理”状态

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.

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 (  get_post_meta($order->id, '_payment_method', true) == '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 (depending on Payment methods)

I didn't want to use the Thank You filter in case the order still got set to On Hold at a previous step, before changing it to my desired status in the filter (a custom status in my case, or Processing in yours). So I used the filter in the Cheque gateway:

add_filter( 'woocommerce_cheque_process_payment_order_status', 'myplugin_change_order_to_agent_processing', 10, 1 );
function myplugin_change_order_to_agent_processing($status){
    return 'agent-processing';
}

I hope this helps someone else out there to know that there is another option.