How to Add Payment Method Info to PDF Invoice in Magento

invoicepdf

I am trying to add payment method's info text to the PDF invoice but I can't figure out the right code.

Any ideas how to do this?

Payment method's info to the PDF invoice

Best Answer

This generally comes down to the specific implementation of the payment method. However the default payment methods provide this functionality by first defining a toPdf method - like this

class Mage_Payment_Block_Info_Purchaseorder extends Mage_Payment_Block_Info
{
    protected function _construct()
    {
        parent::_construct();
        $this->setTemplate('payment/info/purchaseorder.phtml');
    }

    public function toPdf()
    {
        $this->setTemplate('payment/info/pdf/purchaseorder.phtml');
        return $this->toHtml();
    }
}

Which in this case will reference this template file. Your payment method might not have it's own specified toPdf method in which case you will end up using the default template which will affect all not specified payment methods.

To customise admin templates I would suggest your own admin theme, see here for details. Just copy the relevant file to the your theme and add your information there.

Another avenue to look into is to update the payment method to provide its specific information similar to how the CC method does it

Related Topic