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>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度