我试图在Prestashop 1.6.x中更改支付模块的行为,以便从批准源创建客户收据到订单确认页面。
我想提出一个关于最佳方法的建议和一些指导,以达到一个正确的方法。
更具体地说,当用户使用特定的支付模块完成事务时,我需要使用来自外部银行源的POST数据填充订单确认页面,该数据在postProcess()函数中是可用的,以便将其用作一种收据。
据我所知,付款后:
PostProcess()函数(扩展的ModuleFrontController类的一部分)详细阐述外部源的POST数据,并在控制器/前台/validation.php文件中找到。PostProcess()中,如果外部数据正常(即事务已批准),它将重定向到订单确认控制器,如下所示:public function postProcess() {
(...)
$somePostData = '';
//this is the variable that is populated from POST data and i need to show in the confirmation.tpl
$somePostData = Tools::getValue('postdata');
Tools::redirect('index.php?controller=order-confirmation&id_cart=' .
$this->context->cart->id . '&id_module=' .
$this->module->id . '&id_order=' .
$this->module->currentOrder . '&key=' .
$customer->secure_key
);
(...)
}hookPaymentReturn()正在被调用(驻留在主模块php文件中),它加载一个与订单确认页面相关的特定模块模板文件。public function hookPaymentReturn()
{
if (!$this->active) {
return;
}
//this is the variable that I want to populate from the above-mentioned $somePostData found in postProcess()
$receipt_display = 'some data';
$this->context->smarty->assign('receipt_display', $receipt_display);
return $this->display(__FILE__, 'views/templates/hook/confirmation.tpl');
}因此,我的问题是如何使用来自$receipt_display的数据填充$somePostData,如上述两个代码部分所示。
如果上面提到的是错误的,你是否可以提出不同的方法?
谢谢你,小姐
发布于 2019-01-24 19:21:19
这取决于$_POST‘’somePostData‘是否只是一个简单的字符串,如果是的话,将其添加到Tools::redirect作为URL中的下一个参数,如果这是最复杂的数据,您有两个选项,我看到:
hookPaymentReturn中按id获取数据$this->context->cookie->someVar = Tools::getValue('postData');$this->context->cookie->write();
在hookPaymentReturn中阅读它
if ($this->context->cookie->someVar) {
$someVar = $this->context->cookie->someVar;
$this->context->cookie->someVar = null;
$this->context->cookie->write();
}https://stackoverflow.com/questions/54352942
复制相似问题