Php Prestashop 1.5如何在处理订单地址表单时使用钩子保存自定义表单
我在订单地址表中添加了自定义表单 在保存订单地址时,我也想保存自定义表单,但它只保存订单地址 有人能帮我吗Php Prestashop 1.5如何在处理订单地址表单时使用钩子保存自定义表单,php,smarty,prestashop,prestashop-1.5,Php,Smarty,Prestashop,Prestashop 1.5,我在订单地址表中添加了自定义表单 在保存订单地址时,我也想保存自定义表单,但它只保存订单地址 有人能帮我吗 以下是我在项目中如何做到这一点的。这不是一个干净的选择,但它的工作预期 在订单承运人.tpl的顶部,我添加了一个钩子: {hook h="checkCustomForm"} 我已经创建了一个模块/mdoules/customform/customform.php <?php if (!defined('_PS_VERSION_')) exit; class Custom
以下是我在项目中如何做到这一点的。这不是一个干净的选择,但它的工作预期 在订单承运人.tpl的顶部,我添加了一个钩子:
{hook h="checkCustomForm"}
我已经创建了一个模块/mdoules/customform/customform.php
<?php
if (!defined('_PS_VERSION_'))
exit;
class CustomForm extends Module
{
public function __construct()
{
$this->name = 'customform';
$this->tab = 'administration';
$this->version = '1.0.0';
$this->author = 'Florian Lemaitre';
$this->need_instance = 0;
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->l('Custom Form');
$this->description = $this->l('Custom Form');
}
public function install()
{
return $this->createTable()
&& parent::install()
&& $this->registerHook('checkCustomForm');
}
public function hookcheckCustomForm($params)
{
[process your form values here (Tools::getValue('my_value') ...)]
if (error)
{
// We redirect to the Adrress page with a flag 'missing_value' to alert an error
Tools::redirect('index.php?controller=order&step=1&missing_value=true');
}
}
}
以下是我在项目中如何做到这一点的。这不是一个干净的选择,但它的工作预期
在订单承运人.tpl的顶部,我添加了一个钩子:
{hook h="checkCustomForm"}
我已经创建了一个模块/mdoules/customform/customform.php
<?php
if (!defined('_PS_VERSION_'))
exit;
class CustomForm extends Module
{
public function __construct()
{
$this->name = 'customform';
$this->tab = 'administration';
$this->version = '1.0.0';
$this->author = 'Florian Lemaitre';
$this->need_instance = 0;
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->l('Custom Form');
$this->description = $this->l('Custom Form');
}
public function install()
{
return $this->createTable()
&& parent::install()
&& $this->registerHook('checkCustomForm');
}
public function hookcheckCustomForm($params)
{
[process your form values here (Tools::getValue('my_value') ...)]
if (error)
{
// We redirect to the Adrress page with a flag 'missing_value' to alert an error
Tools::redirect('index.php?controller=order&step=1&missing_value=true');
}
}
}
使用重定向时,上下文中的错误消失了。此外,我的表单没有预先填充新值。如何使用重定向维护请求中的错误和数据。或者有其他方法可以做到这一点吗?当我使用重定向时,上下文中的错误就消失了。此外,我的表单没有预先填充新值。如何使用重定向维护请求中的错误和数据。还是有其他方法可以做到这一点?