Jump to content

Display customer "customer messages" indicator on "Orders" tab


Rhapsody
 Share

Recommended Posts

Using PS 1.5.4.2 - in the BO Orders tab, I would like to display an indicator similar to the "New" indicator in the list of orders. This indicator would display if there are any non-private messages associated with the order (e.g. I don't want to see the PayPal status, only if the customer or employee posts a non-private message associated with that order).

 

I know this can be done using an override for AdminOrdersController.php

The override would add the extra field in the list similar to this code that would be inserted just after the 'New' field:

 'message' => array(
  'title' => $this->l('Message'),
  'width' => 25,
  'align' => 'center',
  'type' => 'bool',
  'tmpTableFilter' => true,
  'icon' => array(
0 => 'blank.gif',
1 => array(
 'src' => 'note.png',
 'alt' => $this->l('Customer message'),
)
  ),
  'orderby' => false
 ),

 

The other part of the code would be a sql query located in this code that returns the message variable used for the indicator... this is where I need the help.

 IF((SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer) > 1, 0, 1) as new';
 $this->_join = '
 LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = a.`id_customer`)
 LEFT JOIN `'._DB_PREFIX_.'order_state` os ON (os.`id_order_state` = a.`current_state`)
 LEFT JOIN `'._DB_PREFIX_.'order_state_lang` osl ON (os.`id_order_state` = osl.`id_order_state` AND osl.`id_lang` = '.(int)$this->context->language->id.')';
 $this->_orderBy = 'id_order';
 $this->_orderWay = 'DESC';

 

Can anyone help with the code for that query?

Edited by Rhapsody (see edit history)
  • Like 1

Share this post


Link to post
Share on other sites

  • 3 weeks later...

Hi Rhapsody,

 

Replace the original code by this code on line 91 until 114 (getMessagesByOrderId string) in Message.php

 

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);

}
Edited by Dampers (see edit history)

Share this post


Link to post
Share on other sites

Hi Rhapsody,

 

Replace the original code by this code on line 91 until 114 (getMessagesByOrderId string) in Message.php

 

 

Dampers - I have similar code in a Message.php override attached that inserts the messages in the BO order page as they were in PS 1.4. It was in this post.

 

What I am looking for is how to display a message indicator in the order list (BO Menu, Orders) similar to the "New" indicator on the list.

Message.php

Edited by Rhapsody (see edit history)

Share this post


Link to post
Share on other sites

  • 3 months later...
  • 6 years later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More