Jump to content

Back Office Order Comments No Longer in Order Page


Recommended Posts

Don't you think Prestashop 1.5 having saved order comments appearing in the Customer Service page a really smart move. I mean if order comments are saved at the order page in BO, it SHOULD stay at the order page. Not having us to click on "see all messages" and go through the pile of rows to find the comment thread.

 

It's a pain I can no longer see all the order comments in a single page.

 

How are you guys overcoming this hassle?

  • Like 2

Share this post


Link to post
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

Yep, Prestashop really fucked this one up and really big way! It's really horrible pain in the ass to not to see the freaking important "private notes" in the ORDER page. I and my employees don't give a fuck about the "consolidation of the messages" - c'moon really! How in earth did you prestashop guys think this was a smart move??? We've already screwed up couple orders, because the messages are not there and there's really no easy way to find them...

 

If we have 10+ orders per day (which is kind of small still), and we need to add notes to every third of these, this becomes horrible! So please prestashop, admit you guys were wrong and you'll put the messages back to the orders pages where they should be. I don't object of having them still in the "message hub" but current situation is really fucked up!

  • Like 1

Share this post


Link to post
Share on other sites

  • 2 weeks later...

There is a way to show the thread relative to an order on the adminorders page. It involves overriding the adminorders controller, the customerthread class (just to add one method), the orders view template an copy the message template in the override orders template. Seems complicated but really it isn't; takes a few minutes.

Share this post


Link to post
Share on other sites

  • 3 weeks later...

There is a way to show the thread relative to an order on the adminorders page. It involves overriding the adminorders controller, the customerthread class (just to add one method), the orders view template an copy the message template in the override orders template. Seems complicated but really it isn't; takes a few minutes.

 

Looks like henribaeyens has a kind-of-workaround. I'm not too familiar with code. Can anyone help spell it out? Or is there a better solution?

Share this post


Link to post
Share on other sites

  • 2 weeks later...

If this module would also include order comments on the invoice, I might be interested

 

There is a sort of workarround for this here http://www.prestasho...80#entry1078180

 

I think this might also suffer from the same reason this Order coments dont show on the Order. and the fact they you two seperate tables to store Order comments. a messages table and a customer_message table. i cant for the life of me see why this is a step forward or even a step anywhere. Just seems very confusing....

 

From what i can tell when a order is placed and a message is entered then it gets added to messages. if a message is added later by the customer service it is added to the customer_message table.

 

Why not just use one table and then the current code thats in the order display will still work? anyway

 

/rant off

Edited by qicpf (see edit history)

Share this post


Link to post
Share on other sites

Hello guys,

 

I've had the same problem a few days ago and i read this topic but didn't found any usefull information apart from what henribaeyens wrote "It involves overriding the adminorders controller, the customerthread class (just to add one method), the orders view template an copy the message template in the override orders template." so i found a way to display the messages in the Order Detail page in Back Office.

 

I implemented this change for Prestashop 1.5.2.0. It should work for the other versions.

I will be releasing a module the following days with override that will make it much easier to apply these changes.

Edited by anekeen (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites

You only have to replace in 2 files and add the method "getCustomerMessagesUnread". I didn't bothered with a proper name of the method because i was more focused on making it work.

 

Please let me know if it works, i'm excited in finding this fix and i wanna help coz i know how frutration the Prestashop team can be with lack of support in such issues.

Share this post


Link to post
Share on other sites

You can't see in Back Office, even if you have display_errors "on" on config.php.

Take it easy, step by step, as i did when i implemented the fix.

Revert back to the files before you applied these fixes and do the following steps.

Step 1. Add method in CustomerThread class, add it after the method "getCustomerMessages" at the line 75. Upload the file then see if Back Office is ok.

Step 2. If all is ok, then add the change in AdminOrdersControllers. Check if Back Office is being displayed.

Then finally Step 3. Add the code in the view.tpl in the back office theme, in orders folder.

Share this post


Link to post
Share on other sites

OK it works. I found what i did wrong. Dont just add it to the bottom of the Classes/CustomerThread.php you must add it before the final } or it is outside of the class :)

 

I havent read the code yet but i am assuming it only adds the messages from the Customer messages now and not the original messages table is this correct?

 

I have to go home from work now so it may be an hour before you get a reply to this. Thanks you are a legend.

 

Maybe we can ask the Prestashop guys to include this in the next release. :)

  • Like 1

Share this post


Link to post
Share on other sites

It reads from the table where all the Order messages are stored.

From what i've noticed it's grouped in Threads and each thread has assigned an order and customer so i guess it displays just the comments either the client or the administrator of the shop comments on that order.

 

Btw i'm trying to fix now the issue when the default combination of a produc runs out of stock and it doesn't shift to the next available combination. Do you have that issue/error ? Do you know any leads on that ?

 

I have to go home from work now so it may be an hour before you get a reply to this. Thanks you are a legend.

 

I'm glad i could help :)

Edited by anekeen (see edit history)

Share this post


Link to post
Share on other sites

I havent seen that problem yet. Its got so many bugs we ignore most of them and work arround the rest. if i had the time i would log them. Their way of doing stock astounds me sometimes. and the accounting side of it is somtimes just wierd. I have only been using it a few months so it may just be me. But i cant complain too loudly its free and does what we need.

 

We only run a small uniform store for the Local school.

 

Thanks again for the code. If i get time ill see if i can get it to add the messages in the message table to the code you have done now i have a place to start.

 

Not understanding how the override stuff work i was hoping to find a way of putting code into somewhere that wont get overwritten on every update. But for another day kids screaming for food must go.

 

Phil

 

Edit Spelling

Edited by qicpf (see edit history)

Share this post


Link to post
Share on other sites

OK, After much poking and proding i have a combined Message table and customer messages using the code above from anekeen. Thank you for that!!

 

I have removed the code at a request. This will be made into a module. If you have an Urgent need for it then PM me and we will discuss it.

Edited by qicpf (see edit history)

Share this post


Link to post
Share on other sites

Hi,

 

Awesome! This is great starting point, but as you stated there are some issues, here's couple of them:

*You cannot anymore remove the green tick from the message from the customer (=> Fatal Error) - minor issue, but still

*As you stated it doubles the messages that are in both tables

*It collects ALL the message with that customer, not just the ones related to that order

 

BUT it's still huge improvement compared to the removed functionality that Prestashop team has done.

Share this post


Link to post
Share on other sites

Overriding the class was easy just move it into the override class. But the controllers/admin/AdminOrdersController.php i cant figure out how to do that one.

 

and the template i dont know how either.

Share this post


Link to post
Share on other sites

Hello qicpf,

 

I've removed the code i posted because i am working in transforming it into a module. I have another module on Addons and i know the steps and what it requires to make it available on Addons. Thanks for helping with the messages addition :) If you want you can team up with me and we ll make the module within a few days.

Share this post


Link to post
Share on other sites

  • 2 weeks later...

We agreed to charge the module at $10, however i don't know if we can set this price amount on Prestashop Addons, as the lowest possible is $29 for a module on Addons. So if that would be the case, then it will have to be $29... i will try to contact Prestashop team maybe they can allow the module to be sold for $10.

  • Like 1

Share this post


Link to post
Share on other sites

Hello siomsop,

 

Tonight i'm uploading the module to Prestashop Addons, but it will be 7 days until they approve it.

I can implement the changes directly in your files if you want it within the next tens of minutes.

 

Hello , i have reply to your PM

Share this post


Link to post
Share on other sites

Hello guys,

 

I've told you that i'm developing a module for this bug. After working whole day now and almost finshing to make it a "module" it turned out some variables don't get passed in an overwritten class and i get erronous results.

 

So the solution instead of module fix is overwrite 4 files in 3 locations in Prestashop.

 

With these changes you will be able to:

- see the comments of the customer in his order

- mark his comments as read ( previous fix didn't solved this issue)

- see employer comments added, those that are hidden from the customer are marked with red text "Private"

 

Most of these options were available but limited due to unknown prestashop-related reason.

 

The price for these changes is $15.

 

You just have to send a PM and i'll send you my paypal address. Once the payment is done i will give you the files and instructions where to upload them. It will be a 1-2 minute task for you.The changed files are safe and won't interfere with any existing code inside Prestashop.

 

Please specify your Prestashop version so i will give you the correct files.

 

Respectfully,

Bogdan

Kapsis Webdesign

Edited by Kapsis Webdesign (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites

  • 2 weeks later...

Hello jimmyc,

 

I m working on a bug that is related to Prestashop html entities, for an unknown reason something's wrong when trying to decode from the database, greek characters. Presashop has this issue on their Threads section also, but not in all the Thread Section.

 

Are u interested in the fix ?

Share this post


Link to post
Share on other sites

  • 2 weeks later...

Hello jimmyc,

 

I m working on a bug that is related to Prestashop html entities, for an unknown reason something's wrong when trying to decode from the database, greek characters. Presashop has this issue on their Threads section also, but not in all the Thread Section.

 

Are u interested in the fix ?

I'm interested in your module.

I use 1.5.3.1 and i sent you a private message and waiting for your reply.

Thanks!

Share this post


Link to post
Share on other sites

Hello jimmyc,

 

I m working on a bug that is related to Prestashop html entities, for an unknown reason something's wrong when trying to decode from the database, greek characters. Presashop has this issue on their Threads section also, but not in all the Thread Section.

 

Are u interested in the fix ?

 

Hello Kapsis Webdesign, i replied to your Private Message regarding the module.

Please reply back.

Thanks!

Share this post


Link to post
Share on other sites

Hi,

 

if you don't want to give some money for displaying comments in orders page, i'll give you a solution.

It makes the display of the comments like prestashop < 1.5

 

Just modify the function of the Message class,

Replace the function getMessageByOrderId by this one (on line 91) :

 

public static function getMessagesByOrderId($id_order, $private = false, Context $context = null)
{
  if (!Validate::isBool($private))
   die(Tools::displayError());
 if (!$context)
  $context = Context::getContext();
 $m = Db::getInstance()->executeS('
  SELECT m.*, c.`firstname` AS cfirstname, c.`lastname` AS clastname, e.`firstname` AS efirstname, e.`lastname` AS elastname,
  (COUNT(mr.id_message) = 0 AND m.id_customer != 0) AS is_new_for_me
  FROM `'._DB_PREFIX_.'message` m
  LEFT JOIN `'._DB_PREFIX_.'customer` c ON m.`id_customer` = c.`id_customer`
  LEFT JOIN `'._DB_PREFIX_.'message_readed` mr
   ON mr.`id_message` = m.`id_message`
   AND mr.`id_employee` = '.(isset($context->employee) ? (int)$context->employee->id : '\'\'').'
  LEFT OUTER JOIN `'._DB_PREFIX_.'employee` e ON e.`id_employee` = m.`id_employee`
  WHERE m.`id_order` = '.(int)$id_order.'
  '.(!$private ? ' AND m.`private` = 0' : '').'
  GROUP BY m.id_message
  ORDER BY m.date_add DESC
 ');

 $o = Db::getInstance()->executeS('
  SELECT ct.*, m.*, e.`firstname` AS efirstname, e.`lastname` AS elastname  
  FROM `'._DB_PREFIX_.'customer_thread` ct
  LEFT JOIN `'._DB_PREFIX_.'customer_message` m ON m.`id_customer_thread` = ct.`id_customer_thread`
  LEFT OUTER JOIN `'._DB_PREFIX_.'employee` e ON e.`id_employee` = m.`id_employee`
  WHERE ct.`id_order` = '.(int)$id_order.'
  ORDER BY ct.`date_add` DESC'
 );

 return array_merge($o,$m);

}

 

Works fine

...and its free :)

  • Like 13

Share this post


Link to post
Share on other sites

Hi,

 

if you don't want to give some money for displaying comments in orders page, i'll give you a solution.

It makes the display of the comments like prestashop < 1.5

 

Just modify the function of the Message class,

Replace the function getMessageByOrderId by this one (on line 91) :

 

public static function getMessagesByOrderId($id_order, $private = false, Context $context = null)
{
  if (!Validate::isBool($private))
die(Tools::displayError());
 if (!$context)
  $context = Context::getContext();
 $m = Db::getInstance()->executeS('
  SELECT m.*, c.`firstname` AS cfirstname, c.`lastname` AS clastname, e.`firstname` AS efirstname, e.`lastname` AS elastname,
  (COUNT(mr.id_message) = 0 AND m.id_customer != 0) AS is_new_for_me
  FROM `'._DB_PREFIX_.'message` m
  LEFT JOIN `'._DB_PREFIX_.'customer` c ON m.`id_customer` = c.`id_customer`
  LEFT JOIN `'._DB_PREFIX_.'message_readed` mr
ON mr.`id_message` = m.`id_message`
AND mr.`id_employee` = '.(isset($context->employee) ? (int)$context->employee->id : '\'\'').'
  LEFT OUTER JOIN `'._DB_PREFIX_.'employee` e ON e.`id_employee` = m.`id_employee`
  WHERE m.`id_order` = '.(int)$id_order.'
  '.(!$private ? ' AND m.`private` = 0' : '').'
  GROUP BY m.id_message
  ORDER BY m.date_add DESC
 ');

 $o = Db::getInstance()->executeS('
  SELECT ct.*, m.*, e.`firstname` AS efirstname, e.`lastname` AS elastname  
  FROM `'._DB_PREFIX_.'customer_thread` ct
  LEFT JOIN `'._DB_PREFIX_.'customer_message` m ON m.`id_customer_thread` = ct.`id_customer_thread`
  LEFT OUTER JOIN `'._DB_PREFIX_.'employee` e ON e.`id_employee` = m.`id_employee`
  WHERE ct.`id_order` = '.(int)$id_order.'
  ORDER BY ct.`date_add` DESC'
 );

 return array_merge($o,$m);

}

 

Works fine

...and its free :)

 

The solution works perfectly.

Thank you!

  • Like 1

Share this post


Link to post
Share on other sites

Now my message box is showing errors like that:

 

Notice: Undefined index: cfirstname in /var/www/vhosts/xxxxdocs/cache/smarty/compile/eefd78d74829cc54ce63030dc4021e3bd8487bc9.file.view.tpl.php on line 1282 Notice: Undefined index: clastname in /var/www/vhosts/xxxxx/httpdocs/cache/smarty/compile/eefd78d74829cc54ce63030dc4021e3bd8487bc9.file.view.tpl.php on line 1283

Share this post


Link to post
Share on other sites

Mais je crois que je peux remercier en français ca hoplajetzt, c'est de l'alsacien qui veut dire "Aller Maintenant".

Donc, mille merci pour ce bout de code qui marche à merveille

Tu as tout bon :) 100% alsacien!

Pour la solution que j'ai donnée, n'oublie pas de la placer dans un override si jamais tu as l'intention de faire des maj par la suite!

 

For all, il you want to use the update system of prestashop, don't forget to put the function in an override class!

 

 

Share this post


Link to post
Share on other sites

  • 4 weeks later...

In Prestashop > 1.5, If you want to show all comments / Messages in Order page in BO then just do Following Two steps...

By doing that you can see all comments in order page

 

1) Add Following function to CustomerThread Class after getCustomerMessagesByOrderId Function..

 

public static function getCustomerMessagesByOrderId($id_order)
{
 $sql = 'SELECT ct.*,cm.*, c.`firstname` AS cfirstname, c.`lastname` AS clastname, e.`firstname` AS efirstname, e.`lastname` AS elastname
  FROM '._DB_PREFIX_.'customer_thread ct
  LEFT JOIN '._DB_PREFIX_.'customer_message cm
ON ct.id_customer_thread = cm.id_customer_thread
  LEFT JOIN `'._DB_PREFIX_.'customer` c
ON ct.`id_customer` = c.`id_customer`
  LEFT JOIN '._DB_PREFIX_.'employee e
ON cm.id_employee = e.id_employee
  WHERE id_order = '.(int)$id_order;

 return Db::getInstance()->executeS($sql);
}

 

2) And Change One line in File controllers/admin/AdminOrdersController.php

From

'messages' => Message::getMessagesByOrderId($order->id, true),

to

'messages' => CustomerThread::getCustomerMessagesByOrderId($order->id, true),

 

This is working fine and i have already implemented this..

Edited by divyeshp (see edit history)
  • Like 3

Share this post


Link to post
Share on other sites

  • 2 weeks later...

hoplajetzt solution works but the messages displays the date without the time. This makes the messages sort in random order when both messages occur during the same day.

 

Any fix?

 

In Prestashop > 1.5.4, If you want to show date with time also then..

Open view.tpl file in "your_admin/themes/default/template/controllers/orders/helpers/view/"

 

And replace ( line 793 )

{l s='At'} <i>{dateFormat date=$message['date_add']}

 

with

{l s='At'} <i>{$message['date_add']}

Share this post


Link to post
Share on other sites

  • 2 weeks later...
  • 1 month later...

Yes I did. What should I do now?

 

if you ask me, what you should do is to undo the changes and do the divyeshp solution, he is helping enough by providing his own solution already

 

i did use his solution and it seems to work fine, also helpful the modification to display the message time in addition to date

 

thanks divyeshp ! you helped this man today :D

Share this post


Link to post
Share on other sites

By default latest one should be shown at bottom...

 

Removed hoplajetzt's solution and used yours. Works out pretty neat! If there is a solution to reverse the order to show latest on top it would be great since when replying to customer in the message box, we want to be able to view the latest message while typing.

Share this post


Link to post
Share on other sites

Removed hoplajetzt's solution and used yours. Works out pretty neat! If there is a solution to reverse the order to show latest on top it would be great since when replying to customer in the message box, we want to be able to view the latest message while typing.

 

To show latest message first, Just use solution that i have provided ( #61 ) and replace Following code

public static function getCustomerMessagesByOrderId($id_order)
{
 $sql = 'SELECT ct.*,cm.*, c.`firstname` AS cfirstname, c.`lastname` AS clastname, e.`firstname` AS efirstname, e.`lastname` AS elastname
  FROM '._DB_PREFIX_.'customer_thread ct
  LEFT JOIN '._DB_PREFIX_.'customer_message cm
       ON ct.id_customer_thread = cm.id_customer_thread
  LEFT JOIN `'._DB_PREFIX_.'customer` c
       ON ct.`id_customer` = c.`id_customer`
  LEFT JOIN '._DB_PREFIX_.'employee e
       ON cm.id_employee = e.id_employee
  WHERE id_order = '.(int)$id_order;
 return Db::getInstance()->executeS($sql);
}

 

With This One

public static function getCustomerMessagesByOrderId($id_order)
{
 $sql = 'SELECT ct.*,cm.*, c.`firstname` AS cfirstname, c.`lastname` AS clastname, e.`firstname` AS efirstname, e.`lastname` AS elastname
  FROM '._DB_PREFIX_.'customer_thread ct
  LEFT JOIN '._DB_PREFIX_.'customer_message cm
   ON ct.id_customer_thread = cm.id_customer_thread
  LEFT JOIN `'._DB_PREFIX_.'customer` c
   ON ct.`id_customer` = c.`id_customer`
  LEFT JOIN '._DB_PREFIX_.'employee e
   ON cm.id_employee = e.id_employee
  WHERE id_order = '.(int)$id_order.' ORDER BY cm.id_customer_message DESC';

 return Db::getInstance()->executeS($sql);
}

  • Like 1

Share this post


Link to post
Share on other sites

Removed hoplajetzt's solution and used yours. Works out pretty neat! If there is a solution to reverse the order to show latest on top it would be great since when replying to customer in the message box, we want to be able to view the latest message while typing.

 

Pressed0024, Are you able to get it work with comment #71 ????

Share this post


Link to post
Share on other sites

  • 3 weeks later...

hoplajetzt's solution maintains the order entry information in the message section of the back office.

By order entry info I mean the avs info from your credit card processor, or information if you are entering the order manually.

 

divyeshp solution does not show this original order entry info.

 

if you ask me, what you should do is to undo the changes and do the divyeshp solution, he is helping enough by providing his own solution already

 

i did use his solution and it seems to work fine, also helpful the modification to display the message time in addition to date

 

thanks divyeshp ! you helped this man today :D

Share this post


Link to post
Share on other sites

Hello, i have the following problem ,with both methods (i tried both). I get an error shown on every message, even if the message is shown:

 

Notice: Undefined index: is_new_for_me in [path..]/cache/smarty/compile/6c2173f7f305857a7cdf3a4055e1fab861a4406d.file.view.tpl.php on line 1267 Il

11/04/2013

Share this post


Link to post
Share on other sites

Hello, i have the following problem ,with both methods (i tried both). I get an error shown on every message, even if the message is shown:

 

Notice: Undefined index: is_new_for_me in [path..]/cache/smarty/compile/6c2173f7f305857a7cdf3a4055e1fab861a4406d.file.view.tpl.php on line 1267 Il

11/04/2013

 

 

Hey bepped, I think you have enabled debug that's why this notice is coming up.. You can disable this from file defines.inc.php in config folder..

and replace this

define('_PS_MODE_DEV_', true);

with..

define('_PS_MODE_DEV_', false);

Share this post


Link to post
Share on other sites

hoplajetzt's solution maintains the order entry information in the message section of the back office.

By order entry info I mean the avs info from your credit card processor, or information if you are entering the order manually.

 

divyeshp solution does not show this original order entry info.

 

Hello barrystein, Can yo please clarify more??.. Not getting your point.

Share this post


Link to post
Share on other sites

  • 2 weeks later...

Hello sir....

My problems is something different from other's.

Problems is that the "order" is not showing back office of prestashop 1.5.4.1

 

I am very frustrated with it from last 2 weeks, i have posted our problems and searching everywhere but not found any solution .

I have using latest version of klarna checkout for payment.

 

Thanks in Advance.

Share this post


Link to post
Share on other sites

  • 4 weeks later...

Hi,

 

I have def mode on false / display errors also on off.

 

But getting this:

 

Notice: Undefined index: is_new_for_me in [path..]/cache/smarty/compile/6c2173f7f305857a7cdf3a4055e1fab861a4406d.file.view.tpl.php on line 1267 Il
11/04/2013

Share this post


Link to post
Share on other sites

Hi,

 

if you don't want to give some money for displaying comments in orders page, i'll give you a solution.

It makes the display of the comments like prestashop < 1.5

 

Just modify the function of the Message class,

Replace the function getMessageByOrderId by this one (on line 91) :

 

public static function getMessagesByOrderId($id_order, $private = false, Context $context = null)
{
  if (!Validate::isBool($private))
die(Tools::displayError());
 if (!$context)
  $context = Context::getContext();
 $m = Db::getInstance()->executeS('
  SELECT m.*, c.`firstname` AS cfirstname, c.`lastname` AS clastname, e.`firstname` AS efirstname, e.`lastname` AS elastname,
  (COUNT(mr.id_message) = 0 AND m.id_customer != 0) AS is_new_for_me
  FROM `'._DB_PREFIX_.'message` m
  LEFT JOIN `'._DB_PREFIX_.'customer` c ON m.`id_customer` = c.`id_customer`
  LEFT JOIN `'._DB_PREFIX_.'message_readed` mr
ON mr.`id_message` = m.`id_message`
AND mr.`id_employee` = '.(isset($context->employee) ? (int)$context->employee->id : '\'\'').'
  LEFT OUTER JOIN `'._DB_PREFIX_.'employee` e ON e.`id_employee` = m.`id_employee`
  WHERE m.`id_order` = '.(int)$id_order.'
  '.(!$private ? ' AND m.`private` = 0' : '').'
  GROUP BY m.id_message
  ORDER BY m.date_add DESC
 ');

 $o = Db::getInstance()->executeS('
  SELECT ct.*, m.*, e.`firstname` AS efirstname, e.`lastname` AS elastname  
  FROM `'._DB_PREFIX_.'customer_thread` ct
  LEFT JOIN `'._DB_PREFIX_.'customer_message` m ON m.`id_customer_thread` = ct.`id_customer_thread`
  LEFT OUTER JOIN `'._DB_PREFIX_.'employee` e ON e.`id_employee` = m.`id_employee`
  WHERE ct.`id_order` = '.(int)$id_order.'
  ORDER BY ct.`date_add` DESC'
 );

 return array_merge($o,$m);

}

 

Works fine

...and its free :)

 

I use this all the time after upgrades and works every time. Thanks

 

Not sure about the very latest prestashop updated just the other day,

 

But anyway

 

Just wanted to say thanks again.

Share this post


Link to post
Share on other sites

To show latest message first, Just use solution that i have provided ( #61 ) and replace Following code

public static function getCustomerMessagesByOrderId($id_order)
{
  $sql = 'SELECT ct.*,cm.*, c.`firstname` AS cfirstname, c.`lastname` AS clastname, e.`firstname` AS efirstname, e.`lastname` AS elastname
   FROM '._DB_PREFIX_.'customer_thread ct
   LEFT JOIN '._DB_PREFIX_.'customer_message cm
        ON ct.id_customer_thread = cm.id_customer_thread
   LEFT JOIN `'._DB_PREFIX_.'customer` c
        ON ct.`id_customer` = c.`id_customer`
   LEFT JOIN '._DB_PREFIX_.'employee e
        ON cm.id_employee = e.id_employee
   WHERE id_order = '.(int)$id_order;
  return Db::getInstance()->executeS($sql);
}
With This One

public static function getCustomerMessagesByOrderId($id_order)
{
  $sql = 'SELECT ct.*,cm.*, c.`firstname` AS cfirstname, c.`lastname` AS clastname, e.`firstname` AS efirstname, e.`lastname` AS elastname
   FROM '._DB_PREFIX_.'customer_thread ct
   LEFT JOIN '._DB_PREFIX_.'customer_message cm
    ON ct.id_customer_thread = cm.id_customer_thread
   LEFT JOIN `'._DB_PREFIX_.'customer` c
    ON ct.`id_customer` = c.`id_customer`
   LEFT JOIN '._DB_PREFIX_.'employee e
    ON cm.id_employee = e.id_employee
   WHERE id_order = '.(int)$id_order.' ORDER BY cm.id_customer_message DESC';

  return Db::getInstance()->executeS($sql);
}

 

problem with accents - ľščťžýáíéúôä

post-92886-0-92365500-1378582460_thumb.jpg

post-92886-0-50976200-1378582468_thumb.jpg

Share this post


Link to post
Share on other sites

  • 4 weeks later...
  • 1 month later...
  • 2 weeks later...

In Prestashop > 1.5, If you want to show all comments / Messages in Order page in BO then just do Following Two steps...

By doing that you can see all comments in order page

 

1) Add Following function to CustomerThread Class after getCustomerMessagesByOrderId Function..

 

public static function getCustomerMessagesByOrderId($id_order)
{
  $sql = 'SELECT ct.*,cm.*, c.`firstname` AS cfirstname, c.`lastname` AS clastname, e.`firstname` AS efirstname, e.`lastname` AS elastname
   FROM '._DB_PREFIX_.'customer_thread ct
   LEFT JOIN '._DB_PREFIX_.'customer_message cm
	ON ct.id_customer_thread = cm.id_customer_thread
   LEFT JOIN `'._DB_PREFIX_.'customer` c
	ON ct.`id_customer` = c.`id_customer`
   LEFT JOIN '._DB_PREFIX_.'employee e
	ON cm.id_employee = e.id_employee
   WHERE id_order = '.(int)$id_order;

  return Db::getInstance()->executeS($sql);
}
2) And Change One line in File controllers/admin/AdminOrdersController.php

From

'messages' => Message::getMessagesByOrderId($order->id, true),
to

'messages' => CustomerThread::getCustomerMessagesByOrderId($order->id, true),
This is working fine and i have already implemented this..

 

 

Got it working in 1.4.9.1. It doesn't seem to work now in 1.5.6.1. Any idea?

Share this post


Link to post
Share on other sites

divyeshp's solution in 1.5.6.1 won't show order comments anymore. Have to use back hoplajetzt's solution. But that means we can't have latest order comment at the top.

Hello All,

 

To show order comments on order detail page in back office in 1.5.6.1 you all just need to do following steps and you will done with that i have implemented and tested well on prestashop 1.5.6.1.

 

1) Open CustomerThread.php file from classes folder and add following function just after function getNextThread.

public static function getCustomerMessagesByOrderId($id_order)
{
  $sql = 'SELECT ct.*,cm.*, c.`firstname` AS cfirstname, c.`lastname` AS clastname, e.`firstname` AS efirstname, e.`lastname` AS elastname
   FROM '._DB_PREFIX_.'customer_thread ct
   LEFT JOIN '._DB_PREFIX_.'customer_message cm
    ON ct.id_customer_thread = cm.id_customer_thread
   LEFT JOIN `'._DB_PREFIX_.'customer` c
    ON ct.`id_customer` = c.`id_customer`
   LEFT JOIN '._DB_PREFIX_.'employee e
    ON cm.id_employee = e.id_employee
   WHERE id_order = '.(int)$id_order.' ORDER BY cm.id_customer_message DESC';

  return Db::getInstance()->executeS($sql);
}

2) Open AdminOrdersController.php file from controllers/admin folder and replace this line ( line #1368 )

'messages' => Message::getMessagesByOrderId($order->id, true),

with this code

'messages' => CustomerThread::getCustomerMessagesByOrderId($order->id, true),

3) To show date and time both in messages open file view.tpl from your_Admin/themes/default/template/controllers/orders/helpers/view folder and change this line ( line # 780 )

{l s='At'} <i>{dateFormat date=$message['date_add']}

with this code

{l s='At'} <i>{$message['date_add']}

Follow these threes steps and Enjoy!!!

Edited by divyeshp (see edit history)
  • Like 6

Share this post


Link to post
Share on other sites