Prestashop模块支付挂钩不触发

时间:2016-08-10 13:31:22

标签: php module prestashop payment prestashop-1.6

Prestashop 1.6.1.6需要在付款挂钩中进行一些API调用。但是由于某种原因,钩子没有触发,并且hookPayment方法没有执行。与具有hookPayment的Paypal模块进行比较时,执行此挂钩。我做错了什么?

模块代码尽可能简单

<?php

if(!defined('_ PS_VERSION_'))     出口;

类TestModule扩展了模块{

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)

2 个答案:

答案 0 :(得分:2)

您在功能名称中输了一个拼写错误,它显示public function hoolPayment($params),但应该是public function hookPayment($params)

答案 1 :(得分:2)

PrestaShop模块需要在安装期间扩展PaymentModule才能触发付款挂钩。只是更改扩展或重置也无济于事。