how to get the qty of items invoiced
-
22-10-2019 - |
Question
I'm creating a partial invoice and I'm unable to get the qty invoiced
to send it to the payment gateway.
The code I'd written in my model for capture()
is:
if ($order->hasInvoices()) {
foreach ($order->getInvoiceCollection() as $invoice) {
foreach ($invoice->getAllItems() as $item) {
Mage::log($item->getQtyInvoiced()); // getting qty = 0
}
}
}
also, for the next time I do want to create the invoice then $order->hasInvoices()
returning false
.
Is the above code is right? Any note on debug the invoice items will be appreciated.
Solution
The getQtyInvoiced()
method you are using does not exist. You need to use
$item->getQty();
Then you should be all set.
P.S. For a full list of functions applicable to this object, refer to app/code/core/Mage/Sales/Model/Order/Invoice/Item.php
OTHER TIPS
Try this
if ($order->hasInvoices()) {
foreach ($order->getInvoiceCollection() as $invoice) {
foreach ($invoice->getAllItems() as $item) {
Mage::log($item->getQty());
}
}
}
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange