Promokit Posted June 6, 2013 Share Posted June 6, 2013 Hello. How to create a variable what will be available in the email templates? For prestashop 1.5.2 following scheme worked for me: In the Mail.php file has been created variable $template_vars['{my_var}'] = "value"; and this variable "{my_var}" I used in html files of email templates. But now, in prestashop 1.5.4.1 this scheme doesn't works. Variable is not available in html files. Any suggestions? Link to comment Share on other sites More sharing options...
bellini13 Posted June 7, 2013 Share Posted June 7, 2013 ideally you would locate the controller/class/module responsible for sending the mail, and revise it to include the variable you wish. however even in ps v1.5.4.1, your approach should still work. Are you sure you applied the override properly? Link to comment Share on other sites More sharing options...
Promokit Posted June 7, 2013 Author Share Posted June 7, 2013 Thank you for your reply. Yes, my file Mail.php located in the "override/classes/" folder, but the value of variable is empty. I just checked it once again. Could you please give me a little more description about "responsible for sending the mail"? Thank you in advance Link to comment Share on other sites More sharing options...
bellini13 Posted June 7, 2013 Share Posted June 7, 2013 Why don't you provide exactly what you are trying to accomplish, and exactly what you changed in the Mail class override. In PS v1.5.4.1, there are the following lines. You should just be able to add 1 more line with your variable. $template_vars['{shop_name}'] = Tools::safeOutput(Configuration::get('PS_SHOP_NAME', null, null, $id_shop)); $template_vars['{shop_url}'] = Context::getContext()->link->getPageLink('index', true, Context::getContext()->language->id); $template_vars['{my_account_url}'] = Context::getContext()->link->getPageLink('my-account', true, Context::getContext()->language->id); $template_vars['{guest_tracking_url}'] = Context::getContext()->link->getPageLink('guest-tracking', true, Context::getContext()->language->id); $template_vars['{history_url}'] = Context::getContext()->link->getPageLink('history', true, Context::getContext()->language->id); $template_vars['{color}'] = Tools::safeOutput(Configuration::get('PS_MAIL_COLOR', null, null, $id_shop)); Link to comment Share on other sites More sharing options...
Promokit Posted June 7, 2013 Author Share Posted June 7, 2013 Yes, I did exactly what you suggest I have added the line $template_vars['{my_var}'] = "value"; But {my_var} is empty in the email template Link to comment Share on other sites More sharing options...
bellini13 Posted June 8, 2013 Share Posted June 8, 2013 but apparently you are not doing it correctly, otherwise it would appear as the other variables in the Mail class do appear, like "shop_name" or "color", right? Link to comment Share on other sites More sharing options...
Promokit Posted June 10, 2013 Author Share Posted June 10, 2013 Thank you for all your help, I appreciate it. I don't understand why it works in prestashop 1.5.2, but not in 1.5.4.1. I'll try to figure out it myself. Link to comment Share on other sites More sharing options...
bellini13 Posted June 10, 2013 Share Posted June 10, 2013 are you doing this as an override, or are you changing the original file? if you did this as an override, are you sure your override code is being executed? Link to comment Share on other sites More sharing options...
Promokit Posted June 11, 2013 Author Share Posted June 11, 2013 Yes, my file Mail.php located in the "override/classes/" folder, and YES, it doesn't work. What can be the reason of that? wrong override directory? Link to comment Share on other sites More sharing options...
bellini13 Posted June 11, 2013 Share Posted June 11, 2013 nope, its likely a cache issue. Prestashop stores information about the classes and controllers in a file /cache/class_index.php Open that file and search for the Mail class. Without an override it would look like this... 'Mail' => '', 'MailCore' => 'classes/Mail.php', With the override it should look like this. 'Mail' => 'override/classes/Mail.php', 'MailCore' => 'classes/Mail.php', Link to comment Share on other sites More sharing options...
Promokit Posted June 11, 2013 Author Share Posted June 11, 2013 (edited) Yes, you are absolutely right. I'm working with prestashop about three years and I didn't even think about that. Thank you very much, I really appreciate your help. One more question: Is there is a way to clear that cache in back office? it's necessary for customers. Edited June 11, 2013 by Marek Mnishek (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted June 11, 2013 Share Posted June 11, 2013 I haven't actually looked into how to disable it, but it could be cache setting in the performance section. You could even try to just delete the file and see if it gets rebuilt. Link to comment Share on other sites More sharing options...
Promokit Posted June 12, 2013 Author Share Posted June 12, 2013 Ok, thank you once again. Link to comment Share on other sites More sharing options...
silentRun Posted September 9, 2013 Share Posted September 9, 2013 Yes, you are absolutely right. I'm working with prestashop about three years and I didn't even think about that. Thank you very much, I really appreciate your help. One more question: Is there is a way to clear that cache in back office? it's necessary for customers. You can try this module for flushing the cache, works pretty well Link to comment Share on other sites More sharing options...
Promokit Posted September 9, 2013 Author Share Posted September 9, 2013 Thank you! I already made a module to clean the cache of prestashop classes 1 Link to comment Share on other sites More sharing options...
Ray UK Posted November 7, 2013 Share Posted November 7, 2013 Hi, How would I go about getting the postcode and tracking number from the order into the email as a var ? Im assuming by this mail.php in the overrides, but I dont have a clue how get the info from the order. I need this as our courier uses the postcode and tracking number to track parcels. So I need to enter this into the "In transit" email. Then in the "transit.html" I would need to enter something like this: www trackingcompany.com?postcode=$postcodevar&trackid=$trackingvar Either that, or somehow pass the postcode variable to the tracking url: box on the carriers setup ? ie: www trackingcompany.com?postcode=$postcodevar&trackid=@ Thanks for your help Ray Link to comment Share on other sites More sharing options...
mtblanche Posted December 17, 2013 Share Posted December 17, 2013 I would like to add {id_customer} to one of the email templates (Order Confirmation email). I guess it should be changed in this file first and the new variable should be defined: classes/order/OrderHistory.php I have added code in bold. It didn't work though. Any suggestions? SELECT osl.`template`, c.`lastname`, c.`firstname`, osl.`name` AS osname, c.`email`, os.`module_name`, os.`id_order_state`, c.`id_customer` ... $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...
bellini13 Posted December 17, 2013 Share Posted December 17, 2013 It would be helpful to understand what version of Prestashop you are using ... 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,... } 2 Link to comment Share on other sites More sharing options...
mtblanche Posted December 17, 2013 Share Posted December 17, 2013 Hi bellini13 I am using PS v1.5 and It worked!!!!!! Fantastic. Thank you so very very much. Regards Jan Link to comment Share on other sites More sharing options...
mtblanche Posted February 25, 2014 Share Posted February 25, 2014 Hi bellini13 Would you happen to know what class file to change if one wants the id_customer to be integrated in the registration confirmation email. (account.html)? Thank you? Jan Link to comment Share on other sites More sharing options...
artofadornment Posted January 6, 2016 Share Posted January 6, 2016 I've been reading this thread and I think I know which files to change (PS 1.5.3), but I don't know what code to write. I'd like to be able to add a variable for the customer's email address, and be able to use it in several email templates in the main "mails" folder (order_canceled, cheque, shipped, etc.). If I were to edit classes/Mails.php, what would be the code for adding a new variable for customer email address? $template_vars['{shop_logo}'] = Tools::getShopDomain(true, true).__PS_BASE_URI__.'img/'.Configuration::get('PS_LOGO_MAIL', null, null, $id_shop); $template_vars['{shop_name}'] = Tools::safeOutput(Configuration::get('PS_SHOP_NAME')); $template_vars['{shop_url}'] = Tools::getShopDomain(true, true).__PS_BASE_URI__.'index.php'; $template_vars['{my_account_url}'] = Context::getContext()->link->getPageLink('my-account', true, Context::getContext()->language->id); $template_vars['{guest_tracking_url}'] = Context::getContext()->link->getPageLink('guest-tracking', true, Context::getContext()->language->id); $template_vars['{history_url}'] = Context::getContext()->link->getPageLink('history', true, Context::getContext()->language->id); $template_vars['{color}'] = Tools::safeOutput(Configuration::get('PS_MAIL_COLOR')); $template_vars['{email}'] = ??? Or do I need to edit a different file? Thank you to anyone who can help! Elaine Link to comment Share on other sites More sharing options...
hasniou Posted January 21, 2016 Share Posted January 21, 2016 Hello, How to include tpl file in mail template ? Thank's for your healp Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now