Auto change order status from hold-on to processin

2019-07-23 05:32发布

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?

1条回答
Viruses.
2楼-- · 2019-07-23 05:50

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

查看更多
登录 后发表回答