[英]Prestashop module payment hook not triggering
Prestashop 1.6.1.6 需要在支付掛鈎中進行一些 API 調用。 但是由於某種原因,鈎子沒有觸發,hookPayment 方法沒有執行。 當與也有 hookPayment 的 Paypal 模塊進行比較時,就會執行這個鈎子。 我做錯了什么?
模塊代碼盡可能簡單
<?php
if (!defined('_PS_VERSION_'))
exit;
class TestModule extends Module
{
public function __construct()
{
$this->name = 'testmodule';
$this->tab = 'shipping_logistics';
$this->version = '1.0.0';
$this->author = 'Firstname Lastname';
$this->need_instance = 0;
$this->ps_versions_compliancy = array('min' => '1.6', 'max' => _PS_VERSION_);
$this->bootstrap = true;
parent::__construct();
$this->displayName = $this->l('Test Module');
$this->description = $this->l('Description of my module.');
$this->confirmUninstall = $this->l('Are you sure you want to uninstall?');
}
public function install()
{
if (!parent::install() || !$this->registerHook('payment'))
return false;
return true;
}
public function uninstall()
{
if (!parent::uninstall())
return false;
return true;
}
public function hookPayment($params)
{
ddd($params);
}
}
安裝鈎子后在數據庫中注冊
mysql> select * from module where id_module=75;
+-----------+------------+--------+---------+
| id_module | name | active | version |
+-----------+------------+--------+---------+
| 75 | testmodule | 1 | 1.0.0 |
+-----------+------------+--------+---------+
1 row in set (0,00 sec)
mysql> select * from hook_module where id_module=75;
+-----------+---------+---------+----------+
| id_module | id_shop | id_hook | position |
+-----------+---------+---------+----------+
| 75 | 1 | 1 | 4 |
+-----------+---------+---------+----------+
1 row in set (0,00 sec)
mysql> select * from hook where id_hook=1;
+---------+----------------+---------+-----------------------------------------------------+----------+-----------+
| id_hook | name | title | description | position | live_edit |
+---------+----------------+---------+-----------------------------------------------------+----------+-----------+
| 1 | displayPayment | Payment | This hook displays new elements on the payment page | 1 | 1 |
+---------+----------------+---------+-----------------------------------------------------+----------+-----------+
1 row in set (0,00 sec)
您在函數名稱中public function hoolPayment($params)
字,它說public function hoolPayment($params)
,但應該是public function hookPayment($params)
。
PrestaShop 模塊需要在安裝過程中擴展 PaymentModule 才能觸發支付掛鈎。 僅更改擴展或重置無濟於事。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.