Bulk edit orders to 'wc-processing' status

I searched for an answer but couldn't find any.

How can I allow bulk edit orders to wc-processing status?

Currently I can any other status but this one and it's making the work harder, making me go in each order and change one by one.

Thanks.

Topic woocommerce-offtopic post-status Wordpress

Category Web


This code works to change to order status to processing:

$order = new WC_Order( $order_id );
if ( ! empty( $order ) ) {
    $order->update_status( 'processing' );
}

So you'll need to query all orders by ID and use that code in a loop, like so:

$query = new WC_Order_Query( array(
    'limit' => -1,
    'return' => 'ids',
) );
$orders = $query->get_orders();
foreach ( $orders as $order_id ) {
    $order = new WC_Order( $order_id );
    if ( ! empty( $order ) ) {
        $order->update_status( 'processing' );
    }
}

This code is tested, but always backup your database first - just in case!

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.