Search code examples
wordpresswoocommercehook-woocommercewoocommerce-rest-api

Change orders status by order number in Woocommerce


I would like to know if there is a way that i can change status of a bunch of orders with a list of order numbers, exemple : Change status of this orders from "In progess" to "Completed"

638 637 636 635 634

Thanks


Solution

  • You can loop through ids and use wp_update_post() to update stautus. Here's a list of wc order statuses.

    $order_ids = [ 638, 637, 636, 635, 634 ];
    
    foreach( $order_ids as $id ) {
       wp_update_post([
           'ID'          => $id,
           'post_status' => 'wc-completed'
       ]);
    }