Magento 1.7 – Include Coupon Code in PDF Invoice

couponinvoicemagento-1.7pdf

I am using Magento 1.7. If a coupon code is used I am trying to include it in the PDF invoice. I have been trying the suggestions in this thread http://www.magentocommerce.com/boards/viewthread/56110/ changing app/code/core/Mage/Sales/Model/Order/Pdf/Invoice.php however any changes I make to this file do not appear to do anything to the generated PDF. I also tried overriding it in app/code/local/Mage/Sales/Model/Order/Pdf/Invoice.php and making any changes to this file did not make any difference.

Any suggestions much appreciated, I have spent a long time trying to find answers.

edit

Added this

 /* print coupon code on invoice */
 if($order->getCouponCode()!=""){
    $this->y -= 12;
    $page->drawText('Code: '.$order->getCouponCode(), 450, $this->y, 'UTF-8');
 }

  /* print gift certificate code on invoice */
  if($order->getGiftcertCode()!=""){
     $this->y -= 12;
     $page->drawText('Code: '.$order->getGiftcertCode(), 450, $this->y, 'UTF-8');
  }

In app/code/local/Mage/Sales/Model/Order/Pdf/Invoice.pdf before $this->insertTotals($page, $invoice) on line 149.

Best Answer

I think you have any extension installed which does the PDF rendering for you rather instead of the touched file? just throw a die('test') into the file and you will know.

Beside of this I can recommend Firegento_Pdf which offers a great event for exactly this:

https://github.com/firegento/firegento-pdf/wiki/FAQs#how-can-i-add-notes-to-the-pdfs-programmatically