加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – opencart获取成功页面的最后一个订单ID

发布时间:2020-12-13 22:05:35 所属栏目:PHP教程 来源:网络整理
导读:是否有可能获得最后的订单ID来订购成功页面.?我只是想得到最后的订单ID,所以我可以设置一个链接到我的模板文件success.tpl,该链接将转到最后的订单信息页面. 我曾尝试过controller / checkout / success.php $this-load-model('checkout/order');$order_las
是否有可能获得最后的订单ID来订购成功页面.?我只是想得到最后的订单ID,所以我可以设置一个链接到我的模板文件success.tpl,该链接将转到最后的订单信息页面.
我曾尝试过controller / checkout / success.php

$this->load->model('checkout/order');
$order_last_id = $this->db->getLastId();
$this->data['order_info'] = $this->url->link('account/order/info','order_id=' . $order_last_id,'SSL');

但是,运气不好我得到0订单ID的网址

index.php?route=account/order/info&order_id=0

任何人都可以帮助我获得最后的订单ID.

谢谢…

解决方法

在此代码之前打开/catalog/controller/checkout/success.php

$this->cart->clear();

$this->data['order_id'] = $this->session->data['order_id'];

然后在您的模板中使用if来测试$order_id是否为空

<?php if(!empty($order_id)): ?>
... CODE HERE using $order ID ...
<?php endif; ?>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读