Jump to content

Email Template Change - Customer ID integration


Recommended Posts

Hi, I would like to integrate Customer ID into one of the templates. It is the Order Confirmation email, that starts with:

 

Hi {firstname} {lastname}

Thank you for shopping with {shop_name}!

 

 

So I have tried:

Hi {firstname} {lastname} {id_customer},

Thank you for shopping with {shop_name}!  

 

 

But it didn't work. I guess I imagined it too simple. Am I using a wrong variable?

How can I make this work?

 

Thank you

 

Link to comment
Share on other sites

This thread is a very good one.

http://www.prestashop.com/forums/topic/252825-variables-in-the-email-templates/

 

But wait ... there is more to it, turns out mail.php isn't the only file and that sometimes it may depend on which module you may have in use, this thread provide a great example,

 

http://www.prestashop.com/forums/topic/284556-solved-email-variables/

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

Hi Bill, thank you for a quick reply.

 

do you suggest I do this? (based on the links up) I am not sure how the variable is defined. Is the below correct please?

 

in the file: classes/order/OrderHistory.php

 

Locate lines below:

            $data = array(
                '{lastname}' => $result['lastname'],
                '{firstname}' => $result['firstname'],
                '{id_order}' => (int)$this->id_order,
                '{order_name}' => $order->getUniqReference()
            );

Now replace for this below:

            $data = array(
                '{id_customer}' => $result['id_customer'],
                '{lastname}' => $result['lastname'],
                '{firstname}' => $result['firstname'],
                '{id_order}' => (int)$this->id_order,
                '{order_name}' => $order->getUniqReference()
            );

 

Link to comment
Share on other sites

First thing you should know is that I have never tried what you want to do.  :huh:

 

That said, looking at those 2 threads it seemed that Mail.php was the file that you would update unless you were using a module that used its own process.

 

So have you tried playing with mail.php?

 

Anyone reading this thread is more than welcome to jump in here ... :)

Link to comment
Share on other sites

I was advised to use this:  It still din't work though, any ideas why?

 

SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`, os.`module_name`, os.`id_order_state`,c.`id_customer`
FROM `'._DB_PREFIX_.'order_history` oh
LEFT JOIN `'._DB_PREFIX_.'orders` o ON oh.`id_order` = o.`id_order`
LEFT JOIN `'._DB_PREFIX_.'customer` c ON o.`id_customer` = c.`id_customer`
LEFT JOIN `'._DB_PREFIX_.'order_state` os ON oh.`id_order_state` = os.`id_order_state`
LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = o.`id_lang`)
WHERE oh.`id_order_history` = '.(int)$this->id.' AND os.`send_email` = 1');
if (isset($result['template']) && Validate::isEmail($result['email']))
{
ShopUrl::cacheMainDomainForShop($order->id_shop);
 
$topic = $result['osname'];
$data = array(
'{id_customer}' => $result['id_customer'],
'{lastname}' => $result['lastname'],
'{firstname}' => $result['firstname'],
'{id_order}' => (int)$this->id_order,
'{order_name}' => $order->getUniqReference()
);
Link to comment
Share on other sites

Assuming it is PS v1.5, there is no need to change OrderHistory class.  Just edit/override the PaymentModule class and add the id_customer as

 

$data = array(
'{id_customer}' => $this->context->customer->id,

'{firstname}' => $this->context->customer->firstname,
'{lastname}' => $this->context->customer->lastname,
'{email}' => $this->context->customer->email,
...

}

  • Like 1
Link to comment
Share on other sites

  • 2 months later...
  • 2 months later...
  • 5 months later...

In version 1.6 I have done as follows:

In controllers/front/AuthController.php

search:

                '{firstname}' => $customer->firstname,
                '{lastname}' => $customer->lastname,
                '{email}' => $customer->email,
                
add:

                '{id_customer}' => $customer->id,                
                
Ex:                

                '{firstname}' => $customer->firstname,
                '{lastname}' => $customer->lastname,
                '{email}' => $customer->email,
                '{id_customer}' => $customer->id,
                '{passwd}' => Tools::getValue('passwd')),

                
In email template use:                

{id_customer}

  • Like 1
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...