Jump to content

[Request] Place customer's checkout comments on printed invoice


Recommended Posts

Is there an addon or way to have the comments entered by the customer during CHECKOUT aka the "Customer Instructions" some call it that will print on the invoice itself?

 

I see no way to view the comments unless you open each invoice individually. We print high volumes of orders in batches, so avoiding looking at each order 1 by 1, it would be great to have an addon or way to see all customer comments or instructions printed on the invoice.

Share this post


Link to post
Share on other sites

I have tried to add this also but only got as far as this:

 

Add the below code to classes/PDF.php

 

 $messages = Message::getMessagesByOrderId($order->id, true);
 foreach ($messages as $message)
  {
   $msg = $message['message'];
  }
 $pdf->Cell($width, 10, ($msg), 0, 'L');

 

This outputs the messages, but if have 2 messages or maybe 3 it only outputs the first?

 

Could anybody input on this to diplay all messages?

 

Thanks

Share this post


Link to post
Share on other sites

evolution.x post is almost there.

 

Here's the full solution:

 

Open "PDF.php" file in "classes" directory.

Goto line 830 where you will see

Hook::PDFInvoice($pdf, self::$order->id);

Insert the code below so it will look like

 

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

$pdf->Ln(10);

$pdf->Cell(0,3,"Message(s)",1,1,'L');

foreach ($messages as $message)

{

$msg = wordwrap($message['message'], 165, "\n");

$pdf->Multicell(0,3,$msg,1,0,'L');

}

Hook::PDFInvoice($pdf, self::$order->id);
Edited by yewster (see edit history)
  • Like 3

Share this post


Link to post
Share on other sites
  • 3 months later...

One little fix.

PS saves payment method response, like PayPal, in the same table as customer messages but using value 1 in "private" field so these payment messages are private but ANY, private and not private are included in the invoice using the given code.

Just change:

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

by

$messages = Message::getMessagesByOrderId($order->id, false);

 

to show only customer messages.

Share this post


Link to post
Share on other sites

We would really like the same for Version 1.5x of Prestashop. Seems like such a small thing but i cant find where to add it in 1.5x ?

 

Any help would be appreciated.

 

Phil

Share this post


Link to post
Share on other sites

Ok sort of worked arround this by using a free module

http://www.prestascope.com/lang-en/free-prestashop-modules/24-pdf-invoice-plus.html

and then modifing the code a little to add some of the above.

into the pss_pdfinvoiceplus.php file at line 481

 

//Get Message
$messages = Message::getMessagesByOrderId($order->id, true);
foreach ($messages as $message)
{
$msg = wordwrap($message['message'], 165, "\n");
}
return $html.$msg;

 

Dont forget you may have to add a space or something to the PDF invoice plus config box for something to show up.

 

Now im not claiming this will be what anyone is after. and it only seems to get the mesasges that are entered when the order is first placed but that suits us.

 

If anyone see any issues please feel free to comment and dont forget to support Prestascope.com

  • Like 1

Share this post


Link to post
Share on other sites
  • 4 months later...
what PS version do you use fire2?

 

Hi! Using PS 1.4 . But I solved it changing this line:

 

 

$msg = wordwrap($message['message'], 165, "\n");

 

 

to this :

 

 

$msg = wordwrap(Tools::iconv("ISO-8859-1",self::encoding(),html_entity_decode($message['message'])), 165, "\n");

 

 

 

Hope it helps someone else.

Share this post


Link to post
Share on other sites

I did it using:

 $messages = Message::getMessagesByOrderId($order->id, true);
 foreach ($messages as $message)
  {
$msg = $message['message'];
   $decoded = html_entity_decode($msg);
  }
 $pdf->Cell($width, 10, ($decoded), 0, 'L');

 

instead:

 $messages = Message::getMessagesByOrderId($order->id, true);
 foreach ($messages as $message)
  {
$msg = $message['message'];
  }
 $pdf->Cell($width, 10, ($msg), 0, 'L');

Share this post


Link to post
Share on other sites
  • 3 weeks later...
  • 10 months later...

What I did for PS 1.5 was:

 

1) open /classes/pdf/HTMLTemplateInvoice.php and add the following code to the function getContent();

$customer_message = Message::getMessagesByOrderId((int)$this->order_invoice->id);
foreach ($customer_message as $key => $value)
{
    foreach ($value as $key2 => $value2)
    {
      if($key2=="message")
      {
        $boodschap .= $value2."<br />\n";      
      }
    }
}

and add to the $this->smarty->assign(array :

 'boodschap' => $boodschap,   

This will fill a Smarty-variable called "boodschap" with the order message left by the customer.

 

2) open /pdf/invoice.tpl and add "{boodschap}" anywhere you like in the layout....

Share this post


Link to post
Share on other sites
  • 1 year later...

What I did for PS 1.5 was:

 

1) open /classes/pdf/HTMLTemplateInvoice.php and add the following code to the function getContent();

$customer_message = Message::getMessagesByOrderId((int)$this->order_invoice->id);
foreach ($customer_message as $key => $value)
{
    foreach ($value as $key2 => $value2)
    {
      if($key2=="message")
      {
        $boodschap .= $value2."<br />\n";      
      }
    }
}

and add to the $this->smarty->assign(array :

 'boodschap' => $boodschap,   

This will fill a Smarty-variable called "boodschap" with the order message left by the customer.

 

2) open /pdf/invoice.tpl and add "{boodschap}" anywhere you like in the layout....

 

This gave me server 500 errors when I tried to generate the PDF. Any clue? Using 1.5.4

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
×
×
  • Create New...

Important Information

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