questions
How to update Order Status after user paid
i want to create new order in my custom page (has form).
i use this code :
$order = wc_create_order();
$order->add_product( get_product($id), 1);
$order->set_address( $address, 'billing' );
$order->set_address( $address, 'shipping' );
$newTotal = $order->calculate_totals() + (int)$postprice;
$order->set_total($newTotal);
$order->save();
everything is OK .
when i want to send user to payment page , im using this codes and redirect user to /checkout/order-pay page :
$order_id = $order->get_id();
$order_key = $order->get_order_key();
add_post_meta($order_id, '_payment_method', 'Farakav');
add_post_meta($order_id, '_payment_method_title', 'بانک ملت');
now , everything is good too . but
User Pay order amount as successfully but order-status cant change to proccessing.
Can you help me?
✔️Solution:
Try
$order = wc_get_order($order_id);
$order->update_status('proccessing');