I am trying to get the total number of items in an order and display them in the shipment PDF.
I am using the below code but I doubles the amount of items. For example, if there is 1 item it gets displayed as 2
<?php $order = $this->getPdfHelper()->getOrder();
if ($order->hasInvoices()) {
$invIncrementIDs = array();
$invItems = array();
$total = -0;
foreach ($order->getInvoiceCollection() as $inv) {
$invIncrementIDs[] = $inv->getIncrementId();
foreach ($inv->getAllItems() as $item) {
$invItems[] = $item->getQty();
$total = $total + ($item->getQty());
}
}
}
?>
<br/>
<h3>
<strong><?php echo $this->__("Number of items:") ?> <?php echo $total; ?></strong>
</h3>
I'm not sure why but I'm thinking its to do with:
$total = $total + ($item->getQty());
Could anyone assist?