Creative web design,
Dependable results.

Get a business website you're proud to show off. Contact us today.

FreshBooks

Remote backup, rsync, automatic daily backups
Print Coupon Code or Gift Certificate on Magento Invoice PDF
Monday, 21 February 2011 15:51

One of my clients recently requested adding any applied coupon codes or gift certificate codes to the invoice printed from Magento.  This is actually a pretty quick and easy change.  Below are the steps required to implement this change in Magento 1.4.1.1.

  1. Copy /app/code/core/Mage/Sales/Model/Order/Pdf/Invoice.php to /app/code/local/Mage/Sales/Model/Order/Pdf/Invoice.php
  2. Find the line $page = $this->insertTotals($page, $invoice); in the getPdf function.  This was line 107 for me.
  3. Add the following:
    /* added by Wright Creative Labs */
    /* print coupon code on invoice */
    if($order->getCouponCode()!=""){
    $this->y -=12;
    $page->drawText('Coupon Used: '.$order->getCouponCode(), 450, $this->y, 'UTF-8');
    }
    /* print gift certificate code on invoice */
    if($order->getGiftcertCode()!=""){
    $this->y -=12;
    $page->drawText('Coupon Used: '.$order->getGiftcertCode(), 450, $this->y, 'UTF-8');
    }
  4. Save.
  5. That's it!  Go to the backend to test it out... Sales > Invoices and then try to print an invoice with a coupon code or gift certificate.
 

Add comment


Security code
Refresh