Best,
I'am trying to show the Purchase Order number on the invoices en packingslips. It is the following field.
I have did try to show it in the senders field, by adding PO {{var payment.po_number}} to the System -> Configuration -> Customers -> Customer Configuration -> Adres Templates -> PDF. But this does not show op the details from the purchase order. We also have the firegento pdf extensions installed, and someone sugested that this plugin could help with placing the purchase order number on the invoices en packingslip.
I did find that the purchase order number is saved in sales_flat_order_payment table with column name po_number
I would like to if it is possible to get the purchase order number on the invoices and packingslip. I would also like to know what the best path is to achieve this.
Thanks in advance!
I did find that firegento is able to ad the notes for shipment and invoices. It is doing it with the file located at
/app/code/community/FireGento/Pdf/Model/Observer.php
Notes are added with
public function addInvoiceNotes(Varien_Event_Observer $observer) { $this->_addShippingCountryNotes($observer); $this->_addInvoiceDateNotice($observer); $this->_addInvoiceMaturity($observer); $this->_addPaymentMethod($observer, 'invoice'); $this->_addShippingMethod($observer); $this->_addInvoiceComments($observer); return $this; }
The function _addInvoiceComments looks like
protected function _addInvoiceComments(Varien_Event_Observer $observer) { if (!Mage::getStoreConfigFlag('sales_pdf/invoice/show_comments')) { return $this; } /** @var Mage_Sales_Model_Order_Invoice $invoice */ $invoice = $observer->getInvoice(); /** @var Mage_Sales_Model_Resource_Order_Invoice_Comment_Collection $commentsCollection */ $commentsCollection = $invoice->getCommentsCollection(); $commentsCollection->addVisibleOnFrontFilter(); $result = $observer->getResult(); $notes = $result->getNotes(); foreach ($commentsCollection as $comment) { /** @var $comment Mage_Sales_Model_Order_Invoice_Comment */ $notes[] = $comment->getComment(); } $result->setNotes($notes); return $this; }
I was thinking it might be possible to add a _adPoNumber function to this file. But I don't know how the query the PO number. As stated before the purchase order number is saved in sales_flat_order_payment table with column name po_number. Anybody a suggestion how I can query this PO number and place it in the pdf?
I appreciate any suggestion.
I have been able to ad a custom text to a pdf with Firegento PDF, with the instructions from :
* https://github.com/firegento/firegento-pdf/issues/109
Still having a hard time wrapping my head arround the working with the models. Is there any good information. What I need to know :
* How to identify the correct model to query.
* How to query this model to get the desired results.
Ok, i did finally resolve this issue. I first installed FireGento PDF (https://github.com/firegento/firegento-pdf). Enabled Notes in the admin pannel. Then I create a plugin to ad the PO Number
/app/etc/modules/Mvdd_Pdf.xml
<?xml version="1.0"?> <config> <modules> <Mvdd_Pdf> <active>true</active> <codePool>local</codePool> </Mvdd_Pdf> </modules> </config>
/app/code/local/Mvdd/Pdf/etc/config.xml
<?xml version="1.0"?> <config> <modules> <Mvdd_Pdf> <version>1.0.0</version> </Mvdd_Pdf> </modules> <global> <models> <mvdd_pdf> <class>Mvdd_Pdf_Model</class> </mvdd_pdf> </models> <events> <firegento_pdf_shipment_insert_note> <observers> <mvdd_pdf> <class>mvdd_pdf/observer</class> <method>addPoNumber</method> </mvdd_pdf> </observers> </firegento_pdf_shipment_insert_note> </events> </global> </config>
/app/code/local/Mvdd/Pdf/Model/Observer.php
<?php class Mvdd_Pdf_Model_Observer { public function addPoNumber(Varien_Event_Observer $observer) { // With help from https://github.com/TouchPayments/Magento/blob/master/app/code/local/Touch/TouchPayment/Model/Observer.php $shipment = $observer->getEvent()->getShipment(); $order = $shipment->getOrder(); $payment = $order->getPayment(); $method = $payment->getMethod(); $poNumber = $payment->getPoNumber(); if($method === 'purchaseorder') { $result = $observer->getResult(); $notes = $result->getNotes(); $notes[] = "Inkooporder : $poNumber"; $result->setNotes($notes); } return $this; }