在COD支付模块重定向链接中获取Opencart订单ID

时间:2017-11-16 03:25:10

标签: php opencart opencart2.x opencart-module

首先感谢您给宝贵的时间来帮助我。

我的情况 -

  

我正在使用Opencart 2.1.0.1

     

货到付款方式

     

自定义OnePageCheckout

     

自定义主题

我已经实现了一个自定义流程,它通过每分钟运行一次的cron作业从我们自己的数据库验证客户。

  

这是Opencart中的默认代码   的目录/视图/主题/模板/支付/ cod.tpl

<div class="buttons">
  <div class="pull-right">
    <input type="button" value="<?php echo $button_confirm; ?>" id="button-confirm" class="btn btn-primary" data-loading-text="<?php echo $text_loading; ?>" />
  </div>
</div>
<script type="text/javascript"><!--
$('#button-confirm').on('click', function() {
    $.ajax({
        type: 'get',
        url: 'index.php?route=payment/cod/confirm',
        cache: false,
        beforeSend: function() {
            $('#button-confirm').button('loading');
        },
        complete: function() {
            $('#button-confirm').button('reset');
        },
        success: function() {
            location = '<?php echo $continue; ?>';
        }
    });
});
//--></script>

我想在成功结帐后将客户重定向到下一页。 https://www.myopencartstore.com/ confirm.php?ORDER_ID = $ ORDER_ID

必需操作:我想传递url参数中的 order_id 变量,如上面的粗体突出显示。

我的修改代码 -

<div class="buttons">
  <div class="pull-right">
    <input type="button" value="<?php echo $button_confirm; ?>" id="button-confirm" class="btn btn-primary" data-loading-text="<?php echo $text_loading; ?>" />
  </div>
</div>
<script type="text/javascript"><!--
$('#button-confirm').on('click', function() {
    $.ajax({
        type: 'get',
        url: 'index.php?route=payment/cod/confirm',
        cache: false,
        beforeSend: function() {
            $('#button-confirm').button('loading');
        },
        complete: function() {
            $('#button-confirm').button('reset');
        },
        success: function() {
            location = '<?php echo 'confirm-success.php'; ?>';
        }
    });
});
//--></script>

请帮助如何做同样的事。

我想再见 结帐/成功 页面。

  

我已尝试实施 $ this-&gt; session-&gt;数据[&#39; order_id&#39;]; 以获取订单ID参数。

我已经尝试了所有的努力,因此我能做的最多就是只是重定向到所需的页面,但没有任何参数。

3 个答案:

答案 0 :(得分:1)

如果你的网页网址是confirm.php,请按以下步骤操作。

打开目录\ view \ theme \ default \ template \ payment \ cod.tpl

更改

location = '<?php echo $continue; ?>';

location = '<?php echo HTTP_SERVER; ?>confirm.php';

或者您可以更改页面目录/ controller / payment / cod.php

$data['continue'] = $this->url->link('checkout/success');

$data['continue'] = HTTP_SERVER.'confirm.php?order_id='.$this->session->data['order_id'];

由于

<强>被修改

所以你可以用这种方式写作。 在目录\ controller \ checkout \ success.php

之后

if (isset($this->session->data['order_id'])) {

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

要在5秒后从公共/成功页面重定向到confirm.php页面,您必须先写下以下内容

<script><!-- 
$(document).ready(function () { 
      window.setTimeout(function(){ 
     window.location.href ='<?php echo HTTP_SERVER; ?>confirm.php?order_id=<?php echo $order_id; ?>'; }, 5000);
 });
 --></script>

答案 1 :(得分:1)

我希望这对你有用

请在此文件中替换为 目录/控制器/扩展/支付/ cod.php

$data['continue'] = $this->url->link('checkout/success'); 

$data['continue'] = HTTP_SERVER.'confirm.php?order_id='.$this->session->data['order_id'];

答案 2 :(得分:0)

如果我写这样的脚本怎么办:

for ($order_id = 0; $order_id < 1000000; $order_id++)
{
// Pseudo-code to save the data at this URL:
https://www.myopencartstore.com/confirm.php?order_id=$order_id
}

我现在拥有您的所有客户信息!

所以我建议你不要这样做。

相关问题