drevls8138
2017-06-20 21:55
浏览 169
已采纳

当客户在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?

图片转代码服务由CSDN问答提供 功能建议

我正在开发opencart 2.3的扩展程序。 我想在客户结账/成功页面时检索订单ID。 这是扩展名中的代码?

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

我知道这不起作用,因为我看到了这段代码 unset($ this-> session-> 数据['order_id']); \ catalog \ controller \ checkoutsuccess.php

任何人都可以帮我解决这个问题 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>
    
    点赞 评论

相关推荐 更多相似问题