News:

Looking for documentation? Take a look on our wiki

Main Menu

Invoice order status - Missing sending order "comments"

Started by audiorock, July 07, 2024, 17:14:06 PM

Previous topic - Next topic

audiorock

Hi,

when I try to send a "comment" to a buyer via email (through the virtuemart backend) within the order, they always receive the previous comment and not the real one.

I verified that the file where the email sending function is processed is called: "mail_html_shopper.php"

Inside the file I identified the function that performs the check and which has the "bug":


line 71 to 78
<?php $nb=count($this->orderDetails['history']);
  if(
$this->orderDetails['history'][$nb-1]->customer_notified && !(empty($this->orderDetails['history'][$nb-1]->comments))) { ?>

  <tr>
    <td colspan="3" align="left" style="border: 1px solid #CCCCCC;">
        <?php echo  nl2br($this->orderDetails['history'][$nb-1]->comments); ?>
    </td>
  </tr>
  <?php ?>

In this code we see the variable $nb-1. WHY? This is a BUG?

The problem occurs with virtuemart 4.2.6 and 4.2.12

Can you help me?


AH

Yes this appears to be a bug. 

The reason is that the order status from which the comment field is being taken for this customer message is not within the data $this->orderDetails['history'] data and is why you get the information from the incorrect order status update and not the order status you have just set.

My solution to this is to change the code in the template to use the new order data which contains the information from the order status that has been set:

<?php
// quorvia get the comment from this order status update
if ((isset ($this->newOrderData["customer_notified"]) && ($this->newOrderData["customer_notified"]) == '1')){
if (($this->newOrderData["include_comment"] == '1') && !empty ($this->newOrderData["comments"])) { ?>

<tr>
<td colspan="3" align="left" style="border: 1px solid #CCCCCC;">
<?php echo nl2br($this->newOrderData["comments"]); ?>
</td>
</tr>
<?php }
}
?>

Regards
A

Joomla 4.4.5
php 8.1

audiorock

Hi, your solution is correct and working!
 I inserted it as an override in the template and the problem was solved. Many thanks!

 I request the developers to implement this fix in the next virtuemart update.

 Many thanks for the support.