我怎样才能在 prestashop 的结帐过程中获得挂钩列表?

How could I get a list of hooks in checkout process of prestashop?

我想创建一个自定义模块,它记录一些 activity 的 prestashop。例如,当订单完成时,我会记录用户 ID、时间、金额和设备。

对于这件事,我想我必须使用下订单后调用的钩子;但是,我找不到列出与结帐流程或订单创建相关的所有挂钩的来源。任何人都可以帮助我找到负责这项工作的钩子,或者通过 prestashop 1.6 钩子的一些资源为我提供

我找到了它,也许对其他人有用: 首先,我在安装中添加了两个挂钩和两个常量:

const HOOK_NEW_ORDER = 1;
const HOOK_ACTION_ORDER_STATUS_POST_UPDATE = 2;

actionValidateOrder & actionOrderStatusPostUpdate

if (!parent::install() ||
            !$this->registerHook('actionValidateOrder') ||
            !$this->registerHook('actionOrderStatusPostUpdate') ||
            !Configuration::updateValue('AR_ADMIN_CLUB', 'customer club') ||
            !$this->installModuleTab() ||
            !$this->installDB() ||
            !$this->registerHook("displayBackOfficeHeader") ||
            !$this->insertInitData() ||
            !$this->createFolders()
        )

然后我添加了两个方法来处理这些钩子:

public function hookActionValidateOrder($params)
    {
        if (Module::isEnabled($this->name)) {
            $this->hookOrderProcess(self::HOOK_NEW_ORDER, $params);
        }
    }

public function hookActionOrderStatusPostUpdate($params)
    {
        if (Module::isEnabled($this->name) && (!isset($GLOBALS['hookNewOrder']) || $GLOBALS['hookNewOrder'] != 1)) {
            $this->hookOrderProcess(self::HOOK_ACTION_ORDER_STATUS_POST_UPDATE, $params);
        }
    }

最后,我添加了根据每次订单状态变化执行所需操作的方法:

private function hookOrderProcess($hook, $params)
    {
        if ($hook == self::HOOK_NEW_ORDER) {
            $id_shop   = $params['order']->id_shop;
            $shop_name = $shop_info->name;
            $GLOBALS['hookNewOrder'] = 1;
        } elseif ($hook == self::HOOK_ACTION_ORDER_STATUS_POST_UPDATE) {
            $order_id = $params['id_order'];
            $order_info        = new Order($params['id_order']);
            $id_shop           = $order_info->id_shop;
            $shop_info         = new Shop($id_shop);
            $order_status = $order_info->getCurrentState();

            $customer_id = $order_info->getCustomer()->id;
            $group_id = $order_info->getCustomer()->id_default_group;
            if($order_status == 5){

                $this->actoin_first($order_id, $group_id, $customer_id);

            } elseif($order_status == 6){
                $this->actoin_second($order_id, $group_id, $customer_id,'all');

            }elseif($order_status == 7){
                $this->actoin_third($order_id, $group_id, $customer_id);
            }
        }
    }