mysql - Woocommerce bulk change order status -
i'm having issues woocommerce site. there thousands of old orders stuck on status "processing". these orders have received payment , products have been shipped.
i mark these orders complete without sending completed order e-mails. i'd use following sql query achieve this.
update wp_posts set post_status = 'wc-completed' post_type = 'shop_order' , post_status ='wc-processing' ; do need change other tables or work?
thanks
edit: above code worked me.
you shouldn't need update other tables if you're changing order status. note can achieve within wordpress:
$args = array( 'post_type' => 'shop_order', 'posts_per_page' => -1, 'post_status' => 'wc-processing', ); $orderlist = get_posts($args); foreach ($orderlist $orderpost) { $order = new wc_order($orderpost->id); $order->update_status('completed'); } ...although direct sql query quicker in circumstance.
additionally, if want automatically convert orders completed once they've been paid for, can add following filter:
function mywooautocompleteorder($orderid) { // continue if have $orderid if (!$orderid) { return; } // order $order = wc_get_order($orderid); // update order completed status if ($order) { $order->update_status('completed'); } } add_filter('woocommerce_thankyou', 'mywooautocompleteorder');
Comments
Post a Comment