Jump to content

Hook Account Add


Recommended Posts

Hi, I never worked with hooks on Prestashop so I'm still confused.

 

What is wrong?

 

<?php

class AuthController extends AuthControllerCore
{
    public function hookActionCustomerAccountAdd($params)
    {
        var_dump($params);
    }
}

 

File: override/controllers/front/AuthController.php

 

Thanks!

Link to comment
Share on other sites

nothing wrong, everything works fine, this is an "action" hook, it means that this isn't visible hook. try to break script after var_dump($params);, you should see dump then 

Hi thanks for your reply.

 

I also tried this:

    public function hookActionCustomerAccountAdd($params)
    {
        $customer = $params['newCustomer'];
        $info = $params['_POST'];
        
        return Mail::Send(
            4,
            'account',
            'Test',
            array(
                '{firstname}' => $customer->firstname,
                '{lastname}' => $customer->lastname,
                '{email}' => $customer->email,
                '{passwd}' => $info['passwd']),
            '[email protected]',
            $customer->firstname.' '.$customer->lastname
        );
    }

 

I receive the welcome email on the registered account but not in my mail.

 

EDIT: nothing happens when I "break" the script.

 

Thanks again

Edited by SantiPixel (see edit history)
Link to comment
Share on other sites

Hi, sorry for the bump.

 

Temporaly I'm using the "sendConfirmationMail" because that hook doesn't work for me.

 

class AuthController extends AuthControllerCore
{
    protected function sendConfirmationMail(Customer $customer)
    {
        /* Lo registramos como vendedor ¿? */
        $sql = 'INSERT INTO '. _DB_PREFIX_ .'employee
        (id_profile, id_lang, lastname, firstname, email, passwd, last_passwd_gen, stats_date_from, stats_date_to, bo_color, bo_theme, default_tab, bo_width, bo_show_screencast, active, id_last_order, id_last_customer_message, id_last_customer)
        VALUES
        (5, 3, "'. $customer->lastname .'", "'. $customer->firstname .'", "'. $customer->email .'", "'. $customer->passwd .'", CURRENT_TIMESTAMP, NOW(), NOW(), NULL, "default", 0, 0, 1, 1, 0, 0, 0)
        ';
        Db::getInstance()->execute($sql);
        
        return Mail::Send(
            $this->context->language->id,
            'account',
            Mail::l('Welcome!'),
            array(
                '{firstname}' => $customer->firstname,
                '{lastname}' => $customer->lastname,
                '{email}' => $customer->email,
                '{passwd}' => Tools::getValue('passwd')),
            $customer->email,
            $customer->firstname.' '.$customer->lastname
        );
    }
}

 

And its works fine..

Edited by SantiPixel (see edit history)
Link to comment
Share on other sites

  • 2 months later...

Hi, sorry for the bump.

 

Temporaly I'm using the "sendConfirmationMail" because that hook doesn't work for me.

 

class AuthController extends AuthControllerCore
{
    protected function sendConfirmationMail(Customer $customer)
    {
        /* Lo registramos como vendedor ¿? */
        $sql = 'INSERT INTO '. _DB_PREFIX_ .'employee
        (id_profile, id_lang, lastname, firstname, email, passwd, last_passwd_gen, stats_date_from, stats_date_to, bo_color, bo_theme, default_tab, bo_width, bo_show_screencast, active, id_last_order, id_last_customer_message, id_last_customer)
        VALUES
        (5, 3, "'. $customer->lastname .'", "'. $customer->firstname .'", "'. $customer->email .'", "'. $customer->passwd .'", CURRENT_TIMESTAMP, NOW(), NOW(), NULL, "default", 0, 0, 1, 1, 0, 0, 0)
        ';
        Db::getInstance()->execute($sql);
        
        return Mail::Send(
            $this->context->language->id,
            'account',
            Mail::l('Welcome!'),
            array(
                '{firstname}' => $customer->firstname,
                '{lastname}' => $customer->lastname,
                '{email}' => $customer->email,
                '{passwd}' => Tools::getValue('passwd')),
            $customer->email,
            $customer->firstname.' '.$customer->lastname
        );
    }
}

 

And its works fine..

 

AFAIU there is no such hook, because there is no hook::exec() in AuthController.php::sendConfirmationMail .

Edited by [email protected] (see edit history)
Link to comment
Share on other sites

×
×
  • Create New...