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

我的未来我决定 提交于 2019-12-08 02:41:40

问题


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:


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



来源:https://stackoverflow.com/questions/48917022/auto-change-order-status-from-hold-on-to-processing-in-woocommerce

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!