This may be very simplistic question but I can’t find the answer. I want to add a key/value pair to an array in OpenCart but I can’t seem to get it to work. I’m not sure if what I’m adding to is already an array.
In catalog/controller/account/history.php at line 66 there is the definition of an array:-
$this->data['orders'][] = array(
'order_id' => $result['order_id'],
'name' => $result['firstname'] . ' ' . $result['lastname'],
'status' => $result['status'],
'date_added' => date($this->language->get('date_format_short'), strtotime($result['date_added'])),
'products' => $product_total,
'total' => $this->currency->format($result['total'], $result['currency'], $result['value']),
'href' => HTTPS_SERVER . 'index.php?route=account/invoice&order_id=' . $result['order_id']
);
I want to add to this array using VQMod. VQMod won’t let me replace a line within the definition. I don’t know why, I’ve tried for a couple of hours, it just won’t. So I decided to add a line beneath it like so:-
$this->data[‘orders’][‘amountToPay’] = $paymentState[‘amountToPay’];
This doesn’t work. Not even if I type it directly in the page. I reckon I’ve messed up the syntax but don’t see how unless I’m not understanding the array structure.
Any help appreciated.
You can use the following line –
Because your $this->data[‘orders’] is also a numeric indexed array which contains collection of associative array.
I think your problem will be solved.