how to get the qty of items invoiced
-
22-10-2019 - |
문제
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.
해결책
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
다른 팁
Try this
if ($order->hasInvoices()) {
foreach ($order->getInvoiceCollection() as $invoice) {
foreach ($invoice->getAllItems() as $item) {
Mage::log($item->getQty());
}
}
}
제휴하지 않습니다 magento.stackexchange