我需要在结帐/成功页面上的OpenCart 2.1.0.1模板中添加订单数据。我在view/theme/name/template/common/success.tpl
中添加了以下代码,但它没有显示订单数据,(由于$this->session->data
中没有订单ID,因此值为空)。
<?php if(!empty($orderid)) echo $orderid; ?>
<?php if(!empty($email)) echo $email; ?>
<?php if(!empty($fname)) echo $fname; ?>
<?php if(!empty($lname)) echo $lname; ?>
在/catalog/controller/checkout/success.php
我定义了这些PHP变量:
$this->data['orderid'] = $$this->session->data['order_id'];
$this->data['fname'] = $this->session->data['guest']['firstname'];
$this->data['lname'] = $this->session->data['guest']['lastname'];
$this->load->model('account/order');
$order = $this->model_account_order->getOrder($this->session->data['order_id']);
if($order) {
$this->data['email'] = $order['email'];
}
任何人都可以指导我遗漏的内容以及为什么这些值未在.tpl
文件中加载,以及解决方案是什么。甚至硬编码值也不会在.tpl。
$ this-&gt; session-&gt; data:
的值(
[language] => en
[currency] => USD
[user_id] => 9
[token] => 5ZiNOGeVjCdg4gefNkDLcHzF1zMUVKgA
[account] => guest
[payment_address] => Array
(
[firstname] => sdfsdf
[lastname] => adfafa
[company] =>
[address_1] => test test test
[address_2] =>
[postcode] => 34324
[city] => sdfsdfd
[country_id] => 216
[zone_id] => 3396
[country] => Turkmenistan
[iso_code_2] => TM
[iso_code_3] => TKM
[address_format] =>
[custom_field] => Array
(
)
[zone] => Ahal Welayaty
[zone_code] => A
)
[shipping_address] => Array
(
[firstname] => sdfsdf
[lastname] => adfafa
[company] =>
[address_1] => test test test
[address_2] =>
[postcode] => 34324
[city] => sdfsdfd
[country_id] => 216
[zone_id] => 3396
[country] => Turkmenistan
[iso_code_2] => TM
[iso_code_3] => TKM
[address_format] =>
[zone] => Ahal Welayaty
[zone_code] => A
[custom_field] => Array
(
)
)
)
答案 0 :(得分:0)
是$ data ['order']位在
$this->load->model('checkout/order');
$data['order'] = $this->model_checkout_order->getOrder($this->session->data['order_id']);
应该不是吗?
$this->load->model('checkout/order');
$order = $this->model_checkout_order->getOrder($this->session->data['order_id']);