drevls8138 2017-06-20 21: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 22: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 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog