Jump to content

Email customer created by admin from control panel


HT915

Recommended Posts

Hello

this feature is not available in prestashop by default.

 

you can achieve this with modifications of AdminCustomersController.php

add there function

     /**
     * sendConfirmationMail
     * @param Customer $customer
     * @return bool
     */
    protected function sendConfirmationMail(Customer $customer)
    {
        if (!Configuration::get('PS_CUSTOMER_CREATION_EMAIL')) {
            return true;
        }

        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 modify function processAdd() to:

    public function processAdd()
    {
        if (Tools::getValue('submitFormAjax')) {
            $this->redirect_after = false;
        }
        // Check that the new email is not already in use
        $customer_email = strval(Tools::getValue('email'));
        $customer = new Customer();
        if (Validate::isEmail($customer_email)) {
            $customer->getByEmail($customer_email);
        }
        if ($customer->id) {
            $this->errors[] = Tools::displayError('An account already exists for this email address:').' '.$customer_email;
            $this->display = 'edit';
            return $customer;
        } elseif (trim(Tools::getValue('passwd')) == '') {
            $this->validateRules();
            $this->errors[] = Tools::displayError('Password can not be empty.');
            $this->display = 'edit';
        } elseif ($customer = parent::processAdd()) {
            $this->context->smarty->assign('new_customer', $customer);
            $this->sendConfirmationMail($customer);
            return $customer;
        }
        return false;
    }

(i added sendConfirmationMail() function to last if condition

 

 

customer will receive the email then, the same as customer received while register during standard register process

Link to comment
Share on other sites

Thank you Vekia, I tried exactly what you suggested but still no luck.

No errors but no email in customer inbox either.

My system seems to be properly configured as I receive the test email you send from "advanced parameters".

Any other idea?

Link to comment
Share on other sites

code looks okay, it should send messages properly. 

 

please go to adv. parameters > emails

you can find there "emails log" with all emails that shop sent.

do you see on this list "welcome" email associated with email that you created in shop back office ?


code looks okay, it should send messages properly. 

 

please go to adv. parameters > emails

you can find there "emails log" with all emails that shop sent.

do you see on this list "welcome" email associated with email that you created in shop back office ?

Link to comment
Share on other sites

code looks okay, it should send messages properly. 

 

please go to adv. parameters > emails

you can find there "emails log" with all emails that shop sent.

do you see on this list "welcome" email associated with email that you created in shop back office ?

code looks okay, it should send messages properly. 

 

please go to adv. parameters > emails

you can find there "emails log" with all emails that shop sent.

do you see on this list "welcome" email associated with email that you created in shop back office ?

 

 

I'm afraid there is no list, only an "log emails" button which is set to YES.

Link to comment
Share on other sites

$this->sendConfirmationMail($customer) eval to false, I'm digging trying to figure how to add some extra debugging, maybe you can give me some hint about that.

 

Tried with

if(!$this->sendConfirmationMail($customer))
{
    die();
}

But there is no output.

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

Alright found something in the logs

 

 

Error - La siguiente plantilla de correo no se encuentra: /var/www/html/shop/mails/es/account.txt

 

which translates in "The following email template was not found", or something.

 

I noticed /var/www/html/shop/mails/en/ has a lot of files but there is only lang.php at /var/www/html/shop/mails/es/

 

Is there a module or package I am missing?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...