artofadornment Posted March 8, 2013 Share Posted March 8, 2013 (edited) Hi! This is an odd one. I noticed that "{carrier}" is used in the order_conf.html email template and new_order.html email template and when emailed, shows the name of the carrier selected for the order. I'd like to include that info in a couple of other emails the customer receives when I update order status, including the shipped.html template. Well, I figured it would be as easy as typing in "{carrier}" just like "{shop name}" etc., but for some reason it doesn't work. I'm using PS 1.5.3, is there something I need to check or edit in order to be able to do this? Thanks in advance! Elaine Edited March 10, 2013 by artofadornment (see edit history) Link to comment Share on other sites More sharing options...
PascalVG Posted March 8, 2013 Share Posted March 8, 2013 Hi Elaine, An Email is send with the following command: Mail::Send( (int)$order->id_lang, 'order_conf', Mail::l('Order confirmation', (int)$order->id_lang), $data, $this->context->customer->email, $this->context->customer->firstname.' '.$this->context->customer->lastname, null, null, $file_attachement, null, _PS_MAIL_DIR_, false, (int)$order->id_shop ); As you can see there is a $data on line 5. This is an array what contains all kind of data that you may want to use in the Email, so you have to define this and adjust it to your specific needs. It can be that you have to add a line like this to your specific $data array: (example from paymentmudule.php, PS 1.5.3.1) '{carrier}' => $virtual_product ? Tools::displayError('No carrier') : $carrier->name, So check where your specific Email is created, and just before that find the $data array definition. Add a line like defined above and see if it works Hope I don't forget anything... Pascal. Link to comment Share on other sites More sharing options...
artofadornment Posted March 8, 2013 Author Share Posted March 8, 2013 (edited) Hi Pascal, thanks for your reply. I found a location for the in_transit.html email in controllers/admin/AdminOrdersController.php around line 300: $templateVars = array( '{followup}' => str_replace('@', $order->shipping_number, $carrier->url), '{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{id_order}' => $order->id, '{order_name}' => $order->getUniqReference() ); if (@Mail::Send((int)$order->id_lang, 'in_transit', Mail::l('Package in transit', (int)$order->id_lang), $templateVars, $customer->email, $customer->firstname.' '.$customer->lastname, null, null, null, null, _PS_MAIL_DIR_, true, (int)$order->id_shop)) ...but I still can't find anything anywhere for shipped.html I will try adding the {carrier} line and see what happens (I am an amateur at this so please forgive me if I seem very simplistic). Edit: It worked, thank you! Although that still leaves me with the problem of not being able to add it to the shipped.html email. Any idea where I would have to make changes for that? It seems that there is nothing specified for "Mail::l('Shipped'," anywhere, so it must be some generic setting for all email templates. Edited March 8, 2013 by artofadornment (see edit history) Link to comment Share on other sites More sharing options...
artofadornment Posted March 8, 2013 Author Share Posted March 8, 2013 After some exploration, I think to add the {carrier} data to shipped.html (and other order status emails perhaps) that line needs to be inserted somewhere after line 327 on controllers/admin/AdminOrdersController.php however I am not sure where or what else might need to be added to make it work. line 327: section starts with comment /* Change order state, add a new entry in order history and send an e-mail to the customer if needed */ so it looks like that might be the right area. Ideas? Link to comment Share on other sites More sharing options...
PascalVG Posted March 10, 2013 Share Posted March 10, 2013 Hi Elaine, For if you didn't work it out yet, Normally look for the ::send(...) string The first parameter is the language needed, Second is the template of the email containing the text The third is a header The fourth is the array with near table fields At line 440 you see an array that is given to the send function as the fourth parameter, called $varsTpl (Short for Variables for template) I presume you can add your lines here and then adjust the template file as you wish. Good luck exploring! Pascal Link to comment Share on other sites More sharing options...
artofadornment Posted March 10, 2013 Author Share Posted March 10, 2013 (edited) I found it and it worked, thank you!! That was just the section I needed. Line 352 had: $templateVars = array(); so I changed it to: $templateVars = array('{carrier}' => $virtual_product ? Tools::displayError('No carrier') : $carrier->name); For anyone else using PS 1.5.3 and wanting to add the carrier name to in_transit.html, add this to roughly line 304 (insert among the other variables listed) of controllers/admin/AdminOrdersController.php '{carrier}' => $virtual_product ? Tools::displayError('No carrier') : $carrier->name, and for adding carrier name to shipped.html change line 352 as described above. Thank you for the help Pascal! Edited March 10, 2013 by artofadornment (see edit history) Link to comment Share on other sites More sharing options...
maio Posted March 27, 2013 Share Posted March 27, 2013 Hi, I was looking a way to insert the {carrier} in the "shipping" mail and I found this post... on the next lines you can find how I changed the code, can you check if something is wrong because it doesn't change anything and on the in transit mail i still have {carrier} instead of the actual name $templateVars = array( '{followup}' => str_replace('@', $order->shipping_number, $carrier->url), '{firstname}' => $customer->firstname, '{lastname}' => $customer->lastname, '{id_order}' => $order->id, '{carrier}' => $virtual_product ? Tools::displayError('No carrier') : $carrier->name, '{order_name}' => $order->getUniqReference() ); if (@Mail::Send((int)$order->id_lang, 'in_transit', Mail::l('Package in transit', (int)$order->id_lang), $templateVars, $customer->email, $customer->firstname.' '.$customer->lastname, null, null, null, null, _PS_MAIL_DIR_, true, (int)$order->id_shop)) I'm working with 1.5.1.3 in italian Link to comment Share on other sites More sharing options...
artofadornment Posted March 27, 2013 Author Share Posted March 27, 2013 (edited) Hi maio, To get it to work on both In Transit and Shipped emails (thanks to PascalVG's help!) I added this to controllers/admin/AdminOrdersController.php at about line 300, inserted among the existing variables: '{carrier}' => $virtual_product ? Tools::displayError('No carrier') : $carrier->name, And then I changed this, located at about line 350: $templateVars = array(); to this: $templateVars = array('{carrier}' => $virtual_product ? Tools::displayError('No carrier') : $carrier->name); The lines may be different depending on your version, but they should be close. It should work, although I'm not a developer, just an amateur, so if it doesn't hopefully someone else will speak up. Edited March 27, 2013 by artofadornment (see edit history) 1 Link to comment Share on other sites More sharing options...
maio Posted March 29, 2013 Share Posted March 29, 2013 I want it to work only in the in_transit, and I only added the code like my previoius post (around line 300 of AdminOrdersController.php) do I have to change also line 350 , or that's just if I want {carrier} on the shipped mails? Link to comment Share on other sites More sharing options...
artofadornment Posted March 29, 2013 Author Share Posted March 29, 2013 You don't have to change line 350, that is only if you want to use {carrier} on the Shipped email as well. If it's not working maybe check your Performance settings, you should have "force compilation" enabled, and "cache" disabled while you are editing files. Make sure those are set, then re-upload your edited file. If that doesn't work, it may be because your PS version and mine aren't the same. Link to comment Share on other sites More sharing options...
eec Posted August 8, 2016 Share Posted August 8, 2016 Thank you PascalVG I could fix my PS1.6 problem with email template with your explanation of the ::Send signature. Awesome Link to comment Share on other sites More sharing options...
Andrejkov Posted July 4, 2023 Share Posted July 4, 2023 Hello, Any idea how to add this variable {carrier} to shipped.html on PrestaShop 1.7.8? Regards. 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