zaglebie Posted October 25, 2013 Share Posted October 25, 2013 (edited) Is there any variable for customer email ?I mean when i create some email templates (you know like bankwire,shipped,contact form etc) then i can put some variables like {id_order} and customer will get his correct order numberBUT what about customer email ?If i would like to create mail template with something like "your email address {email}" is there any variable for that ? Edited October 29, 2013 by zaglebie (see edit history) Link to comment Share on other sites More sharing options...
doctorlady Posted October 26, 2013 Share Posted October 26, 2013 Simple put code as: #set($name = ${RequestUser})#set($firstname = $name.substring(0,$name.lastIndexOf(' ')))Dear $firstname for any query reply me Link to comment Share on other sites More sharing options...
zaglebie Posted October 26, 2013 Author Share Posted October 26, 2013 there are variables for name but what about client's email address ? Link to comment Share on other sites More sharing options...
Rolige Posted October 26, 2013 Share Posted October 26, 2013 All the variables are generated from the php file that send the email, you need add first the variable right there and then use in your custom template. Link to comment Share on other sites More sharing options...
zaglebie Posted October 28, 2013 Author Share Posted October 28, 2013 which php file is responsible for variables used in "system" emails like "shipping, bankwire" etc ? inside these templates there are variables like {id_order} which works fine if i put them in new email template but i dont see anywhere variable which would allow me to "print" customers email used for order there is variable {email} used in contact form template but this doesnt work because this is email which visitors put in contact form email field - not email that client used to generate order Link to comment Share on other sites More sharing options...
Rolige Posted October 28, 2013 Share Posted October 28, 2013 Just tell me exactly in wich point and in what template you need include the email address of the customer, you has mentioned 3 or more and each one is different. Link to comment Share on other sites More sharing options...
zaglebie Posted October 28, 2013 Author Share Posted October 28, 2013 i want to create new email template which will be one of statuses which i can send to client inside this email i would like to put variables like order number, clients emailfor order numer there is variable {id_order} and it works, but what about client's email ? Link to comment Share on other sites More sharing options...
Rolige Posted October 28, 2013 Share Posted October 28, 2013 I understand you, but I need to know wich php file send the email because you need add email variable to these file, if I don't know wich the file I can't help you because all variables are generated from these file, that's why I have asked exactly if this email is sent from a module or where is generated. Link to comment Share on other sites More sharing options...
zaglebie Posted October 28, 2013 Author Share Posted October 28, 2013 like i said in AdminStatuses there are templates like shipping, bank wire etc all of these email cant be send only when you enter in back office some order and change status for it Link to comment Share on other sites More sharing options...
Rolige Posted October 29, 2013 Share Posted October 29, 2013 Ok try this, 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( '{email}' => $result['email'], '{lastname}' => $result['lastname'], '{firstname}' => $result['firstname'], '{id_order}' => (int)$this->id_order, '{order_name}' => $order->getUniqReference() ); In your email template use {email} for the customer email, i have not tested, please test in let me know hwat happen. regards. 3 1 Link to comment Share on other sites More sharing options...
zaglebie Posted October 29, 2013 Author Share Posted October 29, 2013 IT WORKEDthanks A LOT ! Link to comment Share on other sites More sharing options...
Rolige Posted October 30, 2013 Share Posted October 30, 2013 IT WORKED thanks A LOT ! A pleasure to help. Regards. Link to comment Share on other sites More sharing options...
zaglebie Posted November 4, 2013 Author Share Posted November 4, 2013 i wonder if its possible to do the same with order date and shipping date ?I mean get variable which would print date when order was made and other variable which would print date of shipping Link to comment Share on other sites More sharing options...
Rolige Posted November 6, 2013 Share Posted November 6, 2013 i wonder if its possible to do the same with order date and shipping date ? I mean get variable which would print date when order was made and other variable which would print date of shipping This need more changes. In the file: classes/order/OrderHistory.php Locate lines below: $result = Db::getInstance()->getRow(' SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`, os.`module_name`, os.`id_order_state` 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( '{lastname}' => $result['lastname'], '{firstname}' => $result['firstname'], '{id_order}' => (int)$this->id_order, '{order_name}' => $order->getUniqReference() ); Now replace for this below: $result = Db::getInstance()->getRow(' SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`, os.`module_name`, os.`id_order_state`, oh.`date_add`, oh.`delivery_date` 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( '{email}' => $result['email'], '{lastname}' => $result['lastname'], '{firstname}' => $result['firstname'], '{id_order}' => (int)$this->id_order, '{order_name}' => $order->getUniqReference(), '{order_date_add}' => $result['date_add'], '{order_delivery_date}' => $result['delivery_date'] ); Now in your email template use: {email} for the customer email {order_date_add} for date add {order_delivery_date} for delivery date (if is not delivered yet, this should be empty) regards. Link to comment Share on other sites More sharing options...
zaglebie Posted November 13, 2013 Author Share Posted November 13, 2013 many many thanks but... i forgot about most important thing - variable for product name (i mean product which was ordered) this is the last thing i need Link to comment Share on other sites More sharing options...
Rolige Posted November 13, 2013 Share Posted November 13, 2013 many many thanks but... i forgot about most important thing - variable for product name (i mean product which was ordered) this is the last thing i need Use this: $result = Db::getInstance()->getRow(' SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`, os.`module_name`, os.`id_order_state`, oh.`date_add`, oh.`delivery_date` 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( '{email}' => $result['email'], '{lastname}' => $result['lastname'], '{firstname}' => $result['firstname'], '{id_order}' => (int)$this->id_order, '{order_name}' => $order->getUniqReference(), '{order_products}' => Db::getInstance()->getValue('SELECT GROUP_CONCAT(" ", `product_name`) AS product_name FROM `'._DB_PREFIX_.'order_detail` WHERE `id_order` = '.(int)$this->id_order), '{order_date_add}' => $result['date_add'], '{order_delivery_date}' => $result['delivery_date'] ); And call products name with {order_products} Link to comment Share on other sites More sharing options...
zaglebie Posted November 13, 2013 Author Share Posted November 13, 2013 you're the man ! Link to comment Share on other sites More sharing options...
rpstanley Posted November 16, 2013 Share Posted November 16, 2013 Be careful with oh.`delivery_date` it should be o.`delivery_date` Actually the code above works great, except that it caused order status changes not sending any emails. That leads me digging through codes for hours Link to comment Share on other sites More sharing options...
mtblanche Posted December 10, 2013 Share Posted December 10, 2013 Hi, I would like to integrate Customer ID into one of the email templates. It is the Order Confirmation email, that starts with: Hi {firstname} {lastname}, Thank you for shopping with {shop_name}! I have tried this: 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() ); But it did not work. Would anyone be able to help me with it. Thank you so much. Link to comment Share on other sites More sharing options...
Rolige Posted December 10, 2013 Share Posted December 10, 2013 Hi, I would like to integrate Customer ID into one of the email templates. It is the Order Confirmation email, that starts with: Hi {firstname} {lastname}, Thank you for shopping with {shop_name}! I have tried this: 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() ); But it did not work. Would anyone be able to help me with it. Thank you so much. That's it because you need add first these parameter in the SQL, eg: SELECT osl.`template`, *** *** *** *** *** *** ***, c.`id_customer` Regards. Link to comment Share on other sites More sharing options...
mtblanche Posted December 10, 2013 Share Posted December 10, 2013 I think that is too advanced for me. Is it a matter of replacing some code or shall I hire somebody to do this for me? Thank you COTOKO for a quick reply Link to comment Share on other sites More sharing options...
Rolige Posted December 10, 2013 Share Posted December 10, 2013 I think that is too advanced for me. Is it a matter of replacing some code or shall I hire somebody to do this for me? Thank you COTOKO for a quick reply I mean to the SQL line that exists little earlier, like this: SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`, os.`module_name`, os.`id_order_state` Just need add the customer id in the end, like this: SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`, os.`module_name`, os.`id_order_state`, c.`id_customer` I hope this help. Link to comment Share on other sites More sharing options...
mtblanche Posted December 10, 2013 Share Posted December 10, 2013 Hi, unfortunately it is still not working. I am defining {id_customer} in the email template but it is still not coming up correctly. 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() ); 1 Link to comment Share on other sites More sharing options...
Rolige Posted December 10, 2013 Share Posted December 10, 2013 The code looks fine, should work, be sure you are editing the right place, there are two similar blocks. 1 Link to comment Share on other sites More sharing options...
mtblanche Posted December 15, 2013 Share Posted December 15, 2013 Hi, yes I have double checked. It still din't work though. Any ideas? I need a unique customer identifier in the email as there can be more customers with the same name so I though {id_customer} would be ideal. Any more thoughts what could be wrong here? Thank you Link to comment Share on other sites More sharing options...
mtblanche Posted December 16, 2013 Share Posted December 16, 2013 any thoughts on this? Link to comment Share on other sites More sharing options...
mtblanche Posted December 17, 2013 Share Posted December 17, 2013 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,... } Link to comment Share on other sites More sharing options...
puspo Posted February 6, 2014 Share Posted February 6, 2014 (edited) 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, ... } This not work's for me on Presta 1.5.6.1 Also not working: '{id_customer}' => $this->context->customer->id_customer, Edited February 6, 2014 by puspo (see edit history) Link to comment Share on other sites More sharing options...
puspo Posted February 6, 2014 Share Posted February 6, 2014 Hi, unfortunately it is still not working. I am defining {id_customer} in the email template but it is still not coming up correctly. 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() ); This work's on my Presta 1.5.6.1 ! THX Link to comment Share on other sites More sharing options...
Guillaume B. Posted May 28, 2014 Share Posted May 28, 2014 I want to do the same thing with the "product_quantity_in_stock" of the table "order_detail" but i block with my SQL request... if someone can help me ? I guess I have to make another "LEFT JOIN" with the table "order_detail" but i failed each time... $result = Db::getInstance()->getRow(' SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`, os.`module_name`, od.`product_quantity_in_stock` 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'])) { $topic = $result['osname']; $data = array( '{lastname}' => $result['lastname'], '{firstname}' => $result['firstname'], '{id_order}' => (int)$this->id_order, '{order_name}' => $order->getUniqReference(), '{order_quantity}' => Db::getInstance()->getValue('SELECT GROUP_CONCAT(" ", `product_quantity_in_stock`) AS product_quantity FROM `'._DB_PREFIX_.'order_detail` WHERE `id_order` = '.(int)$this->id_order), ); Thanks ! Link to comment Share on other sites More sharing options...
HeyVoOn Posted June 10, 2015 Share Posted June 10, 2015 Hello all. I know this topic is a little old. But taking advantage of the topic. I would like to know how I could add in the email template the customer and I receive (notification) before the name of the product, it's picture? Thank you in advance Link to comment Share on other sites More sharing options...
editorstefan Posted July 27, 2017 Share Posted July 27, 2017 Hello, I'm using Prestashop 1.6.1.13 and cant get his to work. I want to display price for shiping excl. tax. '{total_shipping_tax_excl}' => Tools::displayPrice($order->total_shipping_tax_excl, $this->context->currency, false), Is not working, any idea what i should do? Link to comment Share on other sites More sharing options...
Recommended Posts