Arfeen
Arfeen

Reputation: 2623

Opencart: Cannot update order programmatically

I'm developing a payment gateway extension on Opencart. The extension is all completed and working fine as planned.

One thing does not seem to be working which is updating order.

I'm trying to update the order as follows:

$this->load->model('checkout/order');       
$this->model_checkout_order->update($orderid, 2, 'Processing', true);

The $orderid variable contains a valid order id, the record can also be found in database, but it is not updating the order. Am I missing something here ?

Opencart ver. 1.5.x

Thank you

Upvotes: 2

Views: 2895

Answers (2)

Arfeen
Arfeen

Reputation: 2623

Ok I have got the solution to this problem. Adding here for the information.

I was missing "confirm" API at the first place. It has to be confirmed first, otherwise it won't be updated.

// 2 is for status 'Processing'
$this->model_checkout_order->confirm($this->session->data['order_id'], 2);

After that I faced no problem in updating order status.

Upvotes: 1

zoonman
zoonman

Reputation: 1163

Your order status should be greater than zero because model have this check

 $order_query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "order` o LEFT JOIN " . DB_PREFIX . "language l ON (o.language_id = l.language_id) WHERE o.order_id = '" . (int)$order_id . "' AND o.order_status_id > '0'");

Upvotes: 1

Related Questions