6

This questions was originally posted on stackoverflow but I got no responses. But I still need a help solving this problem I've been having.

I have installed Magemaven OrderComment into my CE 1.8.0 and it works fine on both front and back end but wated to show thoes comment when we print invoices. I have been googling and searching but none is working so far.

I found below codes from Magento forum:

foreach ($invoices as $invoice) { $comments = $invoice->getCommentsCollection()->getItems(); foreach ($comments as $comment) { print_r($comment->getData()); //echo $comment->getData('comment'); //echo $comment->getData('created_at'); } } 

and

/*************************** This Is The Invoice Comments ***********************************/ $this->_setFontRegular($page, 10); // Begin table header $page->setFillColor(new Zend_Pdf_Color_RGB(0.93, 0.92, 0.92)); $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5)); $page->setLineWidth(0.5); $page->drawRectangle(25, $this->y, 570, $this->y -15); $this->y -= 10; $page->setFillColor(new Zend_Pdf_Color_RGB(0, 0, 0)); // end table header $_tempY = $this->y; $commentsCollection = $invoice->getCommentsCollection(true); $orderComment = "Order Comments"; $page->drawText($orderComment, 35, $this->y, 'UTF-8'); $this->y -= 15; foreach($commentsCollection as $comm) { $textChunk = wordwrap($comm->getData('comment'), 120, "\n"); foreach(explode("\n", $textChunk) as $textLine){ if ($textLine!=='') { $page->drawText(strip_tags(ltrim($textLine)), 35, $this->y, 'UTF-8'); $this->y -= 15; } } } /*************************** End Invoice Comments ***********************************/ 

Tried each code into the same place after:

/* Add totals */ $this->insertTotals($page, $invoice); if ($invoice->getStoreId()) { Mage::app()->getLocale()->revert(); } } 

in code/core/Mage/Sales/Model/Order/Pdf/Invoice.php file. But no luck. (Second code was able to show title for Order Comment in PDF but not actual comments) Even tried "ordercomment", "OrderComment" or "customer_note" instead of "comment" but nothing showed on PDF invoice.

Surprisingly to see on those forums no one actually figure out, or I just couldn't find the right answer?

As our shop needs to show these comments to a courier, it really helps speed up our whole process. I desperately need you these geniuses help in this forum!

Thanks in advance!

1 Answer 1

5

You are mixing up two different comments here. The code $invoice->getCommentsCollection() will retrieve comments entered via this box

new invoice

which will appear here in the admin

invoice view

The Magemaven comment is saved with the order object - see here

So something like this should do the trick:

$order = $invoice->getOrder(); $orderComment = $order->getCustomerComment()? $order->getCustomerComment() : $order->getCustomerNote(); $page->drawText($orderComment, 35, $this->y, 'UTF-8'); 
1
  • Thanks! It did really work! I'm just a web designer, but now I'm required to know and develop all these php and different coding and stuff. I could google and copy & paste does the job sometimes but when I face something I can't find, really need to know how it works which is hard for non-developer thus these forum can really save my work. Thanks! Commented Sep 8, 2014 at 2:57

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.