Jump to content

Edit History

Janett

Janett

It didn't work because your code is not right...

    /**
     * Install Module.
     *
     * @return bool
     */
    public function install()
    {
        return parent::install()
            && $this->registerHook('actionCustomerAccountAdd');
    }

    /**
     * Retrieve Customer data after account creation.
     *
     * @param array $params
     */
    public function hookActionCustomerAccountAdd(array $params)
    {
        if (isset($params['newCustomer'])
            && Validate::isLoadedObject($params['newCustomer'])
        ) {
            $giftList = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
                SELECT `id_list`
                FROM `ilea_join_list_new_customer`
                WHERE `email` LIKE "'.pSQL($params['newCustomer']->email).'"
            ');

            if ($giftList) {
                foreach ($giftList as $giftListItem) {
                    Db::getInstance()->execute('
                        INSERT INTO `ilea_join_list_customer` (`id_customer`, `id_giftlist`)
                        VALUES (' . (int) $params['newCustomer']->id . ', ' . (int) $giftListItem['id_list'] . ')
                    ');
                }
            }
        }
    }

If your module is already installed, reset it for hook registration.

Janett

Janett

It didn't work because your code is not right...

    /**
     * Install Module.
     *
     * @return bool
     */
    public function install()
    {
        return parent::install()
            && $this->registerHook('actionCustomerAccountAdd');
    }

    /**
     * Retrieve Customer data after account creation.
     *
     * @param array $params
     */
    public function hookActionCustomerAccountAdd(array $params)
    {
        if (isset($params['newCustomer'])
            && Validate::isLoadedObject($params['newCustomer'])
        ) {
            $giftList = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
                SELECT `id_list`
                FROM `ilea_join_list_new_customer`
                WHERE `email` LIKE "'.pSQL($params['newCustomer']->email).'"
            ');

            if ($giftList) {
                foreach ($giftList as $giftListItem) {
                    Db::getInstance()->execute('
                        INSERT INTO `ilea_join_list_customer` (`id_customer`, `id_giftlist`)
                        VALUES (' . (int) $params['newCustomer']->id . ', ' . (int) $giftListItem['id_list'] . ')
                    ');
                }
            }
        }
    }

 

Janett

Janett

It didn't work because your code is not right...

    /**
     * Install Module.
     *
     * @return bool
     */
    public function install()
    {
        return parent::install()
            && $this->registerHook('actionCustomerAccountAdd');
    }

    /**
     * Retrieve Customer data after account creation.
     *
     * @param array $params
     */
    public function hookActionCustomerAccountAdd(array $params)
    {
        if (isset($params['newCustomer'])
            && Validate::isLoadedObject($params['newCustomer'])
        ) {
            $giftList = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
                SELECT `id_list`
                FROM `ilea_join_list_new_customer`
                WHERE email LIKE "'.pSQL($params['newCustomer']->email).'"
            ');

            if ($giftList) {
                foreach ($giftList as $giftListItem) {
                    Db::getInstance()->execute('
                        INSERT INTO `ilea_join_list_customer` (`id_customer`, `id_giftlist`)
                        VALUES (' . (int) $params['newCustomer']->id . ', ' . (int) $giftListItem['id_list'] . ')
                    ');
                }
            }
        }
    }

 

×
×
  • Create New...