teralite Posted January 29, 2015 Share Posted January 29, 2015 Hi all! Im trying to add customer message and date to the deliveryslip but cant get the date to work. <div style="line-height: 1pt"> </div> <table style="width: 100%"> {foreach $messages as $message} <tr> <td style="font-weight:bold; width: 100%">{l s='Message:' pdf='true'}</td> </tr> <tr> <td style="width:100%"> {dateFormat date=$message->date_add full=0} {$message.message} </td> </tr> {/foreach} </table> What am i doing wrong? If i use $order->date_add instead it works fine but its the wrong date i get then, i want the time of the message and not the order. Link to comment Share on other sites More sharing options...
teralite Posted January 30, 2015 Author Share Posted January 30, 2015 Noone that can help me with this? Link to comment Share on other sites More sharing options...
tuk66 Posted January 30, 2015 Share Posted January 30, 2015 Have you tried $message.date_add? 1 Link to comment Share on other sites More sharing options...
teralite Posted January 30, 2015 Author Share Posted January 30, 2015 Yea still no luck with that either. Tried both $message->date.add and $message.date_add Link to comment Share on other sites More sharing options...
tuk66 Posted January 30, 2015 Share Posted January 30, 2015 So where do you take $messages. There is no such array used in the original templates. Link to comment Share on other sites More sharing options...
teralite Posted January 30, 2015 Author Share Posted January 30, 2015 Actually that part is coded by our developer so i dont know, but it gets the message from customers without problem Link to comment Share on other sites More sharing options...
tuk66 Posted January 30, 2015 Share Posted January 30, 2015 There is the date in this array as well? Link to comment Share on other sites More sharing options...
teralite Posted January 30, 2015 Author Share Posted January 30, 2015 Actually im not that good at coding so i dont know. I know there is a date_add in the ps_message and thats the one i want to use. Link to comment Share on other sites More sharing options...
PascalVG Posted January 31, 2015 Share Posted January 31, 2015 Most probably the date_add is not added in the SQL query that creates the $messages array. Tell your developer to add it and it should work. pascal Link to comment Share on other sites More sharing options...
teralite Posted February 2, 2015 Author Share Posted February 2, 2015 (edited) Hi and thanks for your answers. I really want to figure this out since im trying to learn the structure and coding of prestashop. Any idea in what file i can find the array for the string that creates the $messages? Its not a SQL queary in BO atleast, i checked there =) Edited February 2, 2015 by teralite (see edit history) Link to comment Share on other sites More sharing options...
teralite Posted February 2, 2015 Author Share Posted February 2, 2015 Ok i found the array now, anyone that can help me to insert date_add there so i can get this to work? class HTMLTemplateDeliverySlip extends HTMLTemplateDeliverySlipCore { public function getContent() { $customer = new Customer($this->order->id_customer); $email = $customer->email; $messages = $this->getSpecialOrderMessages($this->order->id, $email); $this->smarty->assign(array( 'messages' => $messages )); return parent::getContent(); } public function getSpecialOrderMessages($id_order, $email) { $id_order = (int)($id_order); /*$messages = Message::getMessagesByOrderId($id_order); foreach($messages as $message) $cleanmsg[]['message'] = $message['message']; */ $customer_thread_id = CustomerThread::getIdCustomerThreadByEmailAndIdOrder($email, $id_order); $threads = CustomerThread::getMessageCustomerThreads($customer_thread_id); foreach($threads as $thread) if($thread['private']==0) $cleanmsg[]['message'] = htmlspecialchars_decode($thread['message']); return $cleanmsg; } } Link to comment Share on other sites More sharing options...
teralite Posted February 3, 2015 Author Share Posted February 3, 2015 Anyone that can help me with this please? i need to insert the $message.date_add in the array so i can show it on the delivery slip. Link to comment Share on other sites More sharing options...
PascalVG Posted February 5, 2015 Share Posted February 5, 2015 If you want, (just like the message now comes from customerthread), the customerthread.date_add, try this: (from code you provided above): foreach($threads as $key => $thread) if($thread['private']==0) { // <-- don't forget brackets $cleanmsg[$key]['message'] = htmlspecialchars_decode($thread['message']); $cleanmsg[$key]['date_add'] = htmlspecialchars_decode($thread['date_add']); } // <-- don't forget brackets return $cleanmsg; I think the date_add is already in the function call result of $threads = CustomerThread::getMessageCustomerThreads($customer_thread_id); So it might work like this... Give it a try, pascal. Link to comment Share on other sites More sharing options...
teralite Posted February 5, 2015 Author Share Posted February 5, 2015 (edited) Hi Pascal! Thanks for your reply! Now its a start but it seems that it now makes 2 "lines" on the output. What im trying to do is to write out the "date" and then the "message" on the delivery slip, and with this function it now writes date_add as one line and message as one line. I want it to be like this in the tpl file. <div style="line-height: 1pt"> </div> <table style="width: 100%"> {foreach $messages as $message} <tr> <td style="font-weight:bold; width: 100%">{l s='Message' pdf='true'} {dateFormat date=$message.date_add full=0}</td> </tr> <tr> <td style="width:100%"> {$message.message} </td> </tr> {/foreach} </table> I get the correct date now but it turns out like this on delivery slip : Message 2015/02/03MessageVill ha den uppdelad i två delar om 3 meter vardera med varsin anslutningskabel. and the final output i want to acheive is like this: Message 2015/02/03Vill ha den uppdelad i två delar om 3 meter vardera med varsin anslutningskabel. Edited February 5, 2015 by teralite (see edit history) Link to comment Share on other sites More sharing options...
dani Posted March 13, 2018 Share Posted March 13, 2018 On 1/30/2015 at 10:44 AM, tuk66 said: Have you tried $message.date_add? Maybe off topic, but i wanted to change the invoice date to when the order is done and $order->date_add it was the answer. That's one big stone for me :)) Tnx! 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