在 prestashop 1.4 上使用 hook updateQuantity

using hook updateQuantity on prestashop 1.4

我是 prestashop 新手。

我正在开发 prestashop 1.4,我想在更新库存后调用一个事件。 我读过一些谈论 updateQuantity 挂钩或其他一些定义的挂钩操作的主题。 有人可以通过一个简单的例子让我走上正确的道路

谢谢

您可以使用操作 hookUpdateQuantity。 如果您想首先在模块上使用此操作,则必须在为此挂钩创建函数后在模块函数 install() 上注册。

public function install()
{
  return parent::install() && $this->registerHook('updateQuantity');
}

public function hookUpdateQuantity($params)
{
   // for example send Customer Alert information about product quantity 
    if ($this->_customer_qty && $params['product']['quantity'] > 0)
        $this->sendCustomerAlert((int)$params['product']['id'], 0);
}