woocommerce offtopic - Bulk edit orders to 'wc-processing' status

admin2025-01-08  3

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.

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.

Share Improve this question asked Jan 22, 2019 at 10:10 OmerOmer 1491 gold badge4 silver badges14 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

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!

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736268083a1246.html

最新回复(0)