【问题标题】:Get Opencart Order ID in COD Payment Module Redirect Link在 COD 支付模块重定向链接中获取 Opencart 订单 ID
【发布时间】:2017-11-16 03:25:09
【问题描述】:

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

我的情况 -

我正在使用 Opencart 2.1.0.1

货到付款方式

自定义 OnePageCheckout

自定义主题

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

这是 Opencart 中的默认代码 catalog/view/theme/template/payment/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->session->data['order_id']; 来获取订单 ID 参数。

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

【问题讨论】:

  • 你有没有尝试过?请显示您的步骤

标签: php opencart opencart2.x opencart-module


【解决方案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 秒后从 common/success 页面重定向到 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>

【讨论】:

  • 谢谢!但我不认为你看清楚我的帖子。请检查我需要的链接。您的方法将生成一些链接 store.com/index.php?route=xxxxx。而我想要确认.php,而不是 index.php
  • 好的,所以我认为您在根目录中有一个名为 confirm.php 的直接页面。
  • 所以请在catalog\view\theme\default\template\payment\cod.tpl page location = '';到位置 = 'confirm.php';
  • 我想添加一个功能,因为我在结帐/成功页面上安装了跟踪模块,我无法在 confirm.php (根目录)上提取这些详细信息因此,我认为重定向在从结帐/成功到 confirm.php 的 5 秒内将是一个更好的选择,以免绕过默认程序并完成自定义工作。该怎么做?
  • 我想要 'confirm.php' 页面上的 Order Total 值。因为这将在 javascript 跟踪代码中使用 - 例如“值”参数。 怎么做?
【解决方案2】:

我希望这对你有用

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

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

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

【讨论】:

  • 我想添加一个功能,因为我在结帐/成功页面上安装了跟踪模块,我无法在 confirm.php (根目录)上提取这些详细信息因此,我认为重定向在从结帐/成功到 confirm.php 的 5 秒内将是一个更好的选择,以免绕过默认程序并完成自定义工作。该怎么做?
【解决方案3】:

如果我写一个这样的脚本会怎样:

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
}

我现在有了你所有的客户信息!

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

【讨论】:

猜你喜欢
  • 2013-03-07
  • 1970-01-01
  • 2020-05-15
  • 2013-10-21
  • 2013-01-21
  • 1970-01-01
  • 2015-03-30
  • 2017-10-10
  • 2019-06-26
相关资源
最近更新 更多