comprausa Posted April 12, 2012 Share Posted April 12, 2012 I'm trying to add to the PDF Delivery Slip the Message that a customer send during checkout. Table `ps_message` field `message` selecting the message for that `id_order` with the earliest date. The query look like the second code here, but I dont know how to make it into a usable variable for the pdf: $order = new Order(intval($_GET["id_order"])); SELECT `ps_message`.`message`, MIN(`ps_message`.`date_add`) AS DateTime FROM ps_message WHERE `ps_message`.`id_order` =$order Any clues? Link to comment Share on other sites More sharing options...
bellini13 Posted April 13, 2012 Share Posted April 13, 2012 I would use the Message class. The following will return all the public messages for the supplied order, in date descending order. $result = Message::getMessagesByOrderId($order->id) So you would just have to take the last order returned in $result Link to comment Share on other sites More sharing options...
comprausa Posted April 13, 2012 Author Share Posted April 13, 2012 It makes sense but I'm biting more than I can chew on this one. I counld not do it, I don't even know where to start. I'm new to php. Link to comment Share on other sites More sharing options...
ubergirl Posted April 13, 2012 Share Posted April 13, 2012 I'm interested too... Link to comment Share on other sites More sharing options...
bellini13 Posted April 14, 2012 Share Posted April 14, 2012 if this is something you would like me to create for you, just send me a PM with the version of Prestashop that you use, as well as a sample PDF document showing where you would like the message to appear. I do charge for my services, so we can discuss that in the PM. Link to comment Share on other sites More sharing options...
Andrej Stas Posted April 15, 2012 Share Posted April 15, 2012 (edited) This module adds customer's messages into PDF invoice: http://prestastyle.c...in-pdf-invoice/ Edited June 6, 2012 by Andrej Stas (see edit history) 1 Link to comment Share on other sites More sharing options...
bellini13 Posted April 16, 2012 Share Posted April 16, 2012 that module adds ALL of the customer messages. the requirement is to add the first one. Link to comment Share on other sites More sharing options...
comprausa Posted April 17, 2012 Author Share Posted April 17, 2012 Well done! I can work with this module, thanks Andrej Stas, the community is going to love this contribution. Only issue so far is that the messages are showing the html entity " instead of the punctuation sign " Link to comment Share on other sites More sharing options...
Andrej Stas Posted April 17, 2012 Share Posted April 17, 2012 I'm glad that my module helped. So do you find useful to have checkbox "The first customer's message only"? Link to comment Share on other sites More sharing options...
comprausa Posted April 17, 2012 Author Share Posted April 17, 2012 Yes that checkbox would be very useful. The first message carries the specific instructions for the order. The rest of the customer message history is usually not very relevant to preparing the package. Since you are asking about additional features, May I suggest adding a checkbox to display customer messages only on the "Delivery Slip" The reason being is that an Invoice is an accounting instrument and should not display these messages, but the messages on the "Delivery Slip" will help in preparing the package. Is there a way I can manually hook the messages ONLY to the Delivery Slip and not the invoice? Link to comment Share on other sites More sharing options...
Andrej Stas Posted April 17, 2012 Share Posted April 17, 2012 Ok, the checkbox "The first message only" is added. You can download it again I will take look at the delivery slip and let you know. Thanks for ideas! 1 Link to comment Share on other sites More sharing options...
comprausa Posted April 17, 2012 Author Share Posted April 17, 2012 That was fast! Works like a charm. Thank you Link to comment Share on other sites More sharing options...
TWDesign Posted June 11, 2012 Share Posted June 11, 2012 (edited) I would like to show the customer message on the Shopping Cart Summary Page (shopping-cart.tpl)? Is there a Smarty variable that I can expose in the template? I tried {if isset($oldMessage)}{$oldMessage}{/if} But didnt work. Edited June 11, 2012 by TWDesign (see edit history) Link to comment Share on other sites More sharing options...
Andrej Stas Posted June 11, 2012 Share Posted June 11, 2012 I would like to show the customer message on the Shopping Cart Summary Page (shopping-cart.tpl)? Is there a Smarty variable that I can expose in the template? I tried {if isset($oldMessage)}{$oldMessage}{/if} But didnt work. Sorry, it doesn't work that way. It hooks only into PDFs Your idea could be a subject of a new module. Link to comment Share on other sites More sharing options...
bellini13 Posted June 11, 2012 Share Posted June 11, 2012 I would like to show the customer message on the Shopping Cart Summary Page (shopping-cart.tpl)? Is there a Smarty variable that I can expose in the template? I tried {if isset($oldMessage)}{$oldMessage}{/if} But didnt work. The ParentOrderController.php does this, so you could probably add this or something similar to CartController.php so that your template change would work if ($oldMessage = Message::getMessageByCartId((int)(self::$cart->id))) self::$smarty->assign('oldMessage', $oldMessage['message']); Link to comment Share on other sites More sharing options...
TWDesign Posted July 13, 2012 Share Posted July 13, 2012 Is there a way to add the customer message to the order confirmation email? I am using the message text box as a way for customers to add information about their prefered delivery times so it would be useful to have that on the order confirmation also. Is there a smarty variable like {message} that can be simply added to the email templates? Link to comment Share on other sites More sharing options...
Andrej Stas Posted July 13, 2012 Share Posted July 13, 2012 Hello, the module hooks only into PDF and it's not possible to add any variable to the order confirmation email. Link to comment Share on other sites More sharing options...
enagen Posted July 26, 2012 Share Posted July 26, 2012 Just bought this module, and it doesn't work!!! Module is installed, configurated, but PDFs are not affected. Prestashop 1.4.8.2 Link to comment Share on other sites More sharing options...
ubergirl Posted July 26, 2012 Share Posted July 26, 2012 Just bought this module, and it doesn't work!!! Module is installed, configurated, but PDFs are not affected. Prestashop 1.4.8.2 Did you fill in the "Title of the delivery slip in your language(s):" fields in the configuration? Link to comment Share on other sites More sharing options...
enagen Posted July 26, 2012 Share Posted July 26, 2012 Did you fill in the "Title of the delivery slip in your language(s):" fields in the configuration? Yes i did Link to comment Share on other sites More sharing options...
sltyler1 Posted July 26, 2012 Share Posted July 26, 2012 Just bought this module, and it doesn't work!!! Module is installed, configurated, but PDFs are not affected. Prestashop 1.4.8.2 Thanks, was about to buy this. will wait to make sure it works. Link to comment Share on other sites More sharing options...
Andrej Stas Posted July 26, 2012 Share Posted July 26, 2012 (edited) This module has only satisfied customers so far. I contacted enagen to detect the problem. Edited July 26, 2012 by Andrej Stas (see edit history) Link to comment Share on other sites More sharing options...
sltyler1 Posted July 26, 2012 Share Posted July 26, 2012 This modules has only satisfied customers so far. I contacted enagen to detect the problem. Yes I already like all your products I'm sure you'll get the bug fixed and then I'll download asap The theme maker i'm looking forward to cause I could use it on a site I'm working on now! Link to comment Share on other sites More sharing options...
enagen Posted July 27, 2012 Share Posted July 27, 2012 Thanks Andrej!! Works perfect now! Prestashop 1.4.8.2 I wish to know what was the problem, please email me or post it! Thanks a lot!! very nice support service! Link to comment Share on other sites More sharing options...
Andrej Stas Posted July 27, 2012 Share Posted July 27, 2012 (edited) Thanks Andrej!! Works perfect now! Prestashop 1.4.8.2 I wish to know what was the problem, please email me or post it! Thanks a lot!! very nice support service! The problem was in the main titles: Title of the delivery slip in your language(s): Title of the invoice in your language(s): They were not filled out correctly - it is described in the documentation which is included in the ZIP Edited July 27, 2012 by Andrej Stas (see edit history) Link to comment Share on other sites More sharing options...
Andrej Stas Posted July 27, 2012 Share Posted July 27, 2012 Yes I already like all your products I'm sure you'll get the bug fixed and then I'll download asap The theme maker i'm looking forward to cause I could use it on a site I'm working on now! Thank you! As for the theme maker, you may visit the FB page Link to comment Share on other sites More sharing options...
enagen Posted July 27, 2012 Share Posted July 27, 2012 Thanks a lot!!! I did not understand that the titles should be that way and with accents! never think about that! Thanks for response and support! Regards Link to comment Share on other sites More sharing options...
manolohpm Posted January 15, 2013 Share Posted January 15, 2013 Hi all. Great add-on. Before trying it, will it work with 1.5.2? Thank you. Manolo. Link to comment Share on other sites More sharing options...
patuga Posted June 28, 2013 Share Posted June 28, 2013 yeah... will it work on PS1.5? Link to comment Share on other sites More sharing options...
sunnyb0y Posted September 6, 2013 Share Posted September 6, 2013 Hello, I wonder the same - is this module compatible with 1.5.4.1 and 1.5.5?? How do you buy it from that page (http://prestastyle.com/2012-04-14/customers-messages-in-generated-pdfs/)? I cannot see an add to cart button Link to comment Share on other sites More sharing options...
shroom Posted October 3, 2013 Share Posted October 3, 2013 It works with v1.5.x though special characters (accents...) aren't properly decoded anymore with v1.5.5.0. Link to comment Share on other sites More sharing options...
ukwyspa Posted September 16, 2014 Share Posted September 16, 2014 Who know how to use it in prestashop 1.6 ? display order note in delivery slip.pdf Link to comment Share on other sites More sharing options...
tuk66 Posted September 16, 2014 Share Posted September 16, 2014 This is a possible way http://www.prestashop.com/forums/topic/270613-module-m4-pdf-extensions-with-online-editor/?view=findpost&p=1677379 Link to comment Share on other sites More sharing options...
ukwyspa Posted September 16, 2014 Share Posted September 16, 2014 Ok, but €99 for single solution.. Link to comment Share on other sites More sharing options...
tuk66 Posted September 16, 2014 Share Posted September 16, 2014 Sure, it is not free, but the module is able to do many other things. I am sure that you will get quick return on investment. Link to comment Share on other sites More sharing options...
lovemyseo Posted June 16, 2016 Share Posted June 16, 2016 Sorry, it doesn't work that way. It hooks only into PDFs Your idea could be a subject of a new module. Do you have module for latest version of PS i,e 1.6.1.5 ? aso will it allow to add custom message by shop owner? on invoice and delivery slips? Link to comment Share on other sites More sharing options...
badi3 Posted November 23, 2016 Share Posted November 23, 2016 Solution found on french prestashop forum, works fine om 1.6.1.4 https://www.prestashop.com/forums/topic/275486-r%C3%A9solu-comment-afficher-le-champ-commentaire-client-sur-les-bons-de-livraison/ Link to comment Share on other sites More sharing options...
Pau111111 Posted March 31, 2017 Share Posted March 31, 2017 someone can share the module again? the link doesn't works Link to comment Share on other sites More sharing options...
obewanz Posted September 4, 2023 Share Posted September 4, 2023 (edited) I know this is a long time after the original question and answers presented then, but for those folks who are STILL running PS 1.6.x Maybe this code will be of assistance (because Prestashop documentation is really useless). I will not upload the php or template files because at this point, either YOU need to learn how to do these minor modifications, or your developer does, so here are the instructions: Step 1: Copy your /classes/pdf/HTMLTemplateDeliverySlip.php file to the override folders at /override/classes/pdf/HTMLTemplateDeliverySlip.php(this is the easiest way to get there if you are new to php object oriented programming) Step 2: Search for the following line in that file: $carrier = new Carrier($this->order->id_carrier); Step 3: Modify the code to read like this: /* following line retrieves Customer Order Message */ $customer_message = $this->order->getFirstMessage(); $carrier = new Carrier($this->order->id_carrier); Step 4: Find this block of code: $this->smarty->assign(array( 'order' => $this->order, 'order_details' => $order_details, 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'order_invoice' => $this->order_invoice, 'carrier' => $carrier, 'display_product_images' => Configuration::get('PS_PDF_IMG_DELIVERY') )); Step 5: Modify the code to read like this: $this->smarty->assign(array( 'order' => $this->order, 'order_details' => $order_details, 'delivery_address' => $formatted_delivery_address, 'invoice_address' => $formatted_invoice_address, 'order_invoice' => $this->order_invoice, 'carrier' => $carrier, 'message' => $customer_message, /* adds customer_message to smarty variables */ 'display_product_images' => Configuration::get('PS_PDF_IMG_DELIVERY') )); Step 6: Find this block of code (right after the last one): $tpls = array( 'style_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.style-tab')), 'addresses_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.addresses-tab')), 'summary_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.summary-tab')), 'product_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.product-tab')), 'payment_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.payment-tab')), ); Step 7: Modify the code to read like this: $tpls = array( 'style_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.style-tab')), 'addresses_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.addresses-tab')), 'summary_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.summary-tab')), 'product_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.product-tab')), 'payment_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.payment-tab')), /* creates a template file to display the customer_message in on the form */ 'message_tab' => $this->smarty->fetch($this->getTemplate('delivery-slip.message-tab')), ); Save changes and this file is ready to upload to your /override/classes/pdf/ folder AFTER you have completed the following files AND uploaded them. (If you are working on a non-live site, the order that you upload the files doesn't really matter.) A quick comment: It is absolutely true that you do not need to include the comment lines that describe the changes being made - however, it is my opinion that you should - because somewhere down the line might want to know what you changed, and if you don't work with this code on a daily basis, sometimes even if you do, these comments can provide critical information to refresh your memory why those changes are there, or in the cases of new methods, etc. the parameters and other information expected by the method. We're not quite finished yet, so moving on... Step 8: Create a /pdf/delivery-slip.message-tab.tpl file to setup your message display within the pdf template with the following content: {* * 2007-2015 PrestaShop * * NOTICE OF LICENSE * * This source file is subject to the Academic Free License (AFL 3.0) * that is bundled with this package in the file LICENSE.txt. * It is also available through the world-wide-web at this URL: * http://opensource.org/licenses/afl-3.0.php * If you did not receive a copy of the license and are unable to * obtain it through the world-wide-web, please send an email * to [email protected] so we can send you a copy immediately. * * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade PrestaShop to newer * versions in the future. If you wish to customize PrestaShop for your * needs please refer to http://www.prestashop.com for more information. * * @author PrestaShop SA <contact@prestashop.com> * @copyright 2007-2015 PrestaShop SA * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA * * @author Obewan <obewanz@yahoo.com> * This is a private modification to prestashop 1.6.x to add the customer order message to the generated pdf delivery slip document. * *} <table id="message-tab" width="100%" cellpadding="4" cellspacing="0"> <tr> <td class="message center small grey bold" width="44%">{l s='Order Message' pdf='true'}</td> <td class="message left white" width="56%"> {$message|escape:'html':'UTF-8'|nl2br} </td> </tr> </table> Comments: There are a number of ways to effect this output, but I felt this not only gave you more information on how to modify pdf generated output for other possible future needs, it also tends to provide a much cleaner solution in the end as it leverages the template system to set this apart from the rest of the form code. Note: You can ALSO place this same file in your /themes/your-theme-name/pdf/ folder to lessen the possibility of it getting overridden as there is no provision made to create overrides for template files in Prestashop 1.6.x. Step 9: COPY your /pdf/delivery-slip.tpl file to something like "/pdf/delivery-slip-replaced.tpl (you will use this file to restore your pdf generation template if things go wrong! Step 10: Search for the following code in the /pdf/delivery-slip.tpl file: <tr> <td colspan="7" class="left"> {$payment_tab} </td> <td colspan="5"> </td> </tr> <!-- Hook --> {if isset($HOOK_DISPLAY_PDF)} <tr> <td colspan="12" height="30"> </td> </tr> <tr> <td colspan="2"> </td> <td colspan="10"> {$HOOK_DISPLAY_PDF} </td> </tr> {/if} Step 11: Modify the code to read like this: <tr> <td colspan="7" class="left"> {$payment_tab} </td> <td colspan="5"> </td> </tr> {* -- load message tab and display order message if one exists -- *} {if isset($message)} <tr> <td colspan="7" class="left"> {$message_tab} </td> <td colspan="5"> </td> </tr> {/if} <!-- Hook --> {if isset($HOOK_DISPLAY_PDF)} <tr> <td colspan="12" height="30"> </td> </tr> <tr> <td colspan="2"> </td> <td colspan="10"> {$HOOK_DISPLAY_PDF} </td> </tr> {/if} Comments: I used the smarty comment method to indicate where the new code insert begins, I could just have easily used html comments as those that already appear in the above code snippet. While I prefer to use the smarty comment method whenever possible, the purpose here was simply to show you something new that you may not be aware of. {* comment *} After uploading the files above, the following image depicts the pdf output produced by the above modifications in the standard template: Note: IF you wanted a separator line between the payment and message elements, you could always add a border between them by either inserting a <tr><td class="separator"></td></tr> as the first row of the table in the /pdf/delivery-slip.message-tabl.tpl file OR by using/adding a css directive like table#message-tab {border-top:1px solid #000;} in the /pdf/delivery-style-tab.tpl file. Hopefully presenting the answer in this format will not only allow you to add something that SHOULD HAVE ALREADY BEEN IN THE RELEASED CODE of Prestashop 1.6, but it will also help you to learn more about how to modify your own Prestashop site in the future... or maybe even help out a new developer to the codebase. Edited September 4, 2023 by obewanz (see edit history) 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