Woocommerce – change order status from on-hold to pending payment

If you ever need to change the order status from php here is how to do it.

$order = new WC_Order($order_id);

if (!empty($order)) {
 $order->update_status( 'completed' );
}

Possible values: processing, on-hold, cancelled, completed

This is from woocommerce/includes/abstracts/abstract-wc-order.php

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)