Skip to content
Advertisement

Auto change order status from hold-on to processing in Woocommerce

I would like to change every order from woocommerce with the status ‘HOLD-ON’ to ‘PROCESSING’ with php.

I already tried to write a function in the functions.php file but I failed.

How can I auto change order status from “hold-on” to “processing” in Woocommerce?

Advertisement

Answer

To auto-process orders, you should try the following:

add_action( 'woocommerce_thankyou', 'woocommerce_auto_processing_orders');
function woocommerce_auto_processing_orders( $order_id ) {
    if ( ! $order_id )
        return;

    $order = wc_get_order( $order_id );

    // If order is "on-hold" update status to "processing"
    if( $order->has_status( 'on-hold' ) ) {
        $order->update_status( 'processing' );
    }
}

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

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