OpenCart 添加到数组
这可能是一个非常简单的问题,但我找不到答案。我想向 OpenCart 中的数组添加一个键/值对,但我似乎无法让它工作。我不确定我添加的内容是否已经是一个数组。
在catalog/controller/account/history.php第66行有一个数组的定义:-
$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']
);
我想使用VQMod添加到这个数组。 VQMod 不允许我替换定义中的一行。不知道为什么,我试了好几个小时了,就是不行。所以我决定在它下面添加一行,如下所示:-
$this->data['orders']['amountToPay'] = $ paymentState['amountToPay'];
这是行不通的。即使我直接在页面中输入它也不会。我认为我已经搞乱了语法,但除非我不理解数组结构,否则我不知道如何搞砸。
任何帮助表示赞赏。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用以下行 -
因为您的 $this->data['orders'] 也是一个数字索引数组,其中包含关联数组的集合。
我想你的问题将会得到解决。
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.
使用 vQmod 可以很容易地做到这一点。基本上你需要搜索
并将该行放在它后面。以下是您需要放入自定义 vQmod XML 文件中的内容
Pretty easy to do this using vQmod. Basically you need to search for
and put the line after it. Here's what you need to put in your custom vQmod XML file