Last active
December 2, 2020 17:31
-
-
Save scgoeswild/79c335b2e2a313b720a75ea856d1749f to your computer and use it in GitHub Desktop.
Magento 1.9 add admin order comments to invoice.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* add these lines to /app/code/core/Mage/Sales/Model/Order/Pdf/invoice.php */ | |
/* Add Comments */ | |
$statusHistory = $order->getStatusHistoryCollection()->getData(); | |
$order_comments = ''; | |
foreach($statusHistory as $status) { | |
$new_comment = ''; | |
if ($status['comment']) { | |
if ($new_comment) { | |
$new_comment .= ', '; | |
} | |
$new_comment .= $status['comment']; | |
} | |
if ($new_comment) { | |
if (strlen($order_comments) > 0) { $order_comments .= '; '; } | |
$order_comments .= $new_comment; | |
} | |
} | |
if ($order_comments){ | |
$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); | |
if (strlen($order_comments) > 100) { | |
$line_count = (int)((strlen($order_comments) + 17) / 118); // Excepting first line with order comment label | |
$order_comments_1st = "Order Comments : " . substr($order_comments, 0, 100); | |
$page->drawRectangle(25, $this->y + 5, 570, $this->y - 15 - $line_count * 12); | |
$this->y -= 8; | |
$page->setFillColor(new Zend_Pdf_Color_RGB(0, 0, 0)); | |
$page->drawText($order_comments_1st, 35, $this->y, 'UTF-8'); | |
for ($i = 0; $i < $line_count; $i++) { | |
$begin_point = 100 + i * 118; | |
$order_comments_2nd = substr($order_comments, 100 + $i * 118, 118); | |
$this->y -= 13; | |
$page->drawText($order_comments_2nd, 35, $this->y, 'UTF-8'); | |
} | |
} | |
else{ | |
$page->drawRectangle(25, $this->y + 5, 570, $this->y - 15); | |
$this->y -= 8; | |
$orderComment = "Order Comments : " . $order_comments; | |
$page->setFillColor(new Zend_Pdf_Color_RGB(0, 0, 0)); | |
$page->drawText($orderComment, 35, $this->y, 'UTF-8'); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment