drevls8138 2017-06-20 13:55
浏览 194
已采纳

当客户在opencart扩展中的结帐/成功页面时,如何检索订单ID?

I'm developing an extension for opencart 2.3. I want to retrieve the order Id when a customer comes to checkout/success page. This is my code in the extension?

if(isset($this->request->get['route']) && $this->request->get['route'] == "checkout/success")
{
  if (isset($this->session->data['order_id']) && (!empty($this->session->data['order_id']))) 
     { $order_id = $this->session->data['order_id']; ... }
}

I know this doesn't work because I saw this code unset($this->session->data['order_id']); in \catalog\controller\checkoutsuccess.php.

can anybody help me about this without touching to main document of opencart?

  • 写回答

1条回答 默认 最新

  • dongyu4908 2017-06-20 14:20
    关注

    I have a free vqMod extension that does this very thing. It's at https://www.opencart.com/index.php?route=marketplace/extension/info&extension_id=18125

    Note: To use vqMod extensions, you must first install vqMod for OpenCart. Details and instructions available here: https://github.com/vqmod/vqmod/wiki/Installing-vQmod-on-OpenCart

    You have to save off this value before it gets cleared (as you noted) and then you can display it later. That's what my mod does.

    Logic:

    <file name="catalog/language/en-gb/checkout/success.php">
            <operation info="Add language string">
    
                    <search position="after"><![CDATA[
                    // Text
                    ]]></search>
    
                    <add><![CDATA[
                    $_['text_order']   = 'Your order ID is %s.';
                    ]]></add>
    
            </operation>
    </file>
    <file name="catalog/controller/checkout/success.php">
            <operation info="Save Order ID">
    
                    <search position="after"><![CDATA[
                     if (isset($this->session->data['order_id'])) {
                    ]]></search>
    
                    <add><![CDATA[
                    $this->session->data['last_order_id'] = $this->session->data['order_id'];
                    ]]></add>
    
            </operation>
    </file>
    <file name="catalog/controller/checkout/success.php">
            <operation info="Output Order ID">
    
                    <search position="before"><![CDATA[
                    $data['button_continue']
                    ]]></search>
    
                    <add><![CDATA[
                    $data['text_message'] .= sprintf($this->language->get('text_order'),  $this->session->data['last_order_id']);
                    ]]></add>
    
            </operation>
    </file>
    

    展开全部

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

悬赏问题

  • ¥15 雄安新区高光谱数据集的下载网址打不开
  • ¥66 android运行时native和graphics内存详细信息获取
  • ¥100 求一个c#通过CH341读取数据的Demo,能够读取指定地址值的功能
  • ¥15 rk3566 Android11 USB摄像头 微信
  • ¥15 torch框架下的强化学习DQN训练奖励值浮动过低,希望指导如何调整
  • ¥35 西门子博图v16安装密钥提示CryptAcquireContext MS_DEF_PROV Error of containger opening
  • ¥15 mes系统扫码追溯功能
  • ¥40 selenium访问信用中国
  • ¥20 在搭建fabric网络过程中遇到“无法使用新的生命周期”的报错
  • ¥15 Python中关于代码运行报错的问题
手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部