Prestashop模块:挂钩和订单

use*_*856 5 prestashop prestashop-1.6

我对这个主题有很多疑问

正如标题所述,我需要在下订单并接受付款时找到正确的挂钩.

1.)当下订单(和付款)时,我应该在我的模块中绑定哪个挂钩?

2.)我的印象是没有广泛的钩子,因为一些付款方式将订单状态设置为自动"付款"(如成功的PayPal交易),而其他方法则要求店主手动将状态设置为'所许".是否只有那两个必须被召唤来覆盖大多数情况?

3.)虽然我仍然希望有一个广义的钩子,如果没有,我将如何解决这个问题?绑定"actionPaymentConfirmation"以及"displayPaymentReturn"以涵盖这两种情况?

4.)当我在后台设置订单状态为"付费"时,为什么挂钩"actionPaymentConfirmation"从未被调用过.我的代码看起来像这样

public function install() {

   if (!parent::install() || !$this->registerHook("actionPaymentConfirmation")) {
        return false;
    }
    return true;
}

public function actionPaymentConfirmation($params) {
    print_r($params);   // stepping through with XDebug but the function is never being invoked
}
Run Code Online (Sandbox Code Playgroud)

5.)有没有人知道一个免费的模块做同样的事情我可以深入研究以获得更好的想法?

6.)或者可能更容易覆盖Prestashops核心类来解决我的问题?为了分解它,我想在下订单并且状态设置为接受或远程接受付款后执行.

嗯,我希望我不是同时要求很多东西,但正如你所看到的,我有兴趣掌握这些东西,但在此过程中遇到了一些麻烦.现在一直在努力,特别是在没有运气的情况下寻找几天的答案.

问候!

Pre*_*per 9

我假设您使用的是PrestaShop 1.5

1 actionValidateOrder(用于新订单)&actionOrderStatusPostUpdate(在这里您可以查看"付费"状态)

2喜欢1.

3喜欢1.

4钩子是actionOrderStatusPostUpdate

public function install()
{
    return (parent::install()
        AND $this->registerHook('newOrder')
        AND $this->registerHook('actionOrderStatusPostUpdate'));
}

public function hookNewOrder($params)
{
    return $this->hookActionOrderStatusPostUpdate($params);
}

public function hookActionOrderStatusPostUpdate($params)
{
    //$params['newOrderStatus'] // after status changed
    //$params['orderStatus'] // after order is placed
}
Run Code Online (Sandbox Code Playgroud)

6看5.

注意:actionValidateOrder newOrder的新名称(别名)