Magento get invoice from order
Magento get invoice from order : Basically Mage::getModel(‘sales/order’) is used to get the invoice collection using this invoice collection is loaded from the order. As we know invoices are created against the order. An order can have one or more than one invoice. Here in this tutorial we are going to explain how to get the all invoice of an order.
.
Magento get invoice from order
You can get all invoice of the an order as below which show how to get invoice increment ids and grand total from order. –
Magento get invoice from order id:
<?php $orderId = 1245; $order = Mage::getModel('sales/order')->load($orderId); $invoiceIncrementIds = array(); if ($order->hasInvoices()) { foreach ($order->getInvoiceCollection() as $invoce) { $invoiceIncrementIds[] = $invoce->getIncrementId(); } } ?> |
The above example will give you all the invoices created against the order id 1245. You can get other details of invoice same as grandtoal, increment id.
Get More About Invoice From Order
Let us get more details of invoices from order as below –
Get Subtotal | Grand total | Shipping Amount From Invoice Of Order
Get Subtotal | Grand total | Shipping Amount From Invoice Of Order:
<?php $orderId = 1245; $order = Mage::getModel('sales/order')->load($orderId); if ($order->hasInvoices()) { $grandTotal = array(); $subTotal = array(); $shippingAmount = array(); $invoiceIncrementIds = array(); foreach ($order->getInvoiceCollection() as $invoce) { $invoiceIncrementId = $invoce->getIncrementId(); $invoiceIncrementIds[] = $invoiceIncrementId; $grandTotal[$invoiceIncrementId] = $invoice->getGrandTotal(); $subTotal[$invoiceIncrementId] = $invoice->getSubTotal(); $shippingAmount [$invoiceIncrementId] = $invoice->getShippingAmount(); } } ?> |
Advertisements