Magento Get the total number of items ordered on the success page.

I went through all of Google and did not find a working solution for my requirement. Please, help.

I am trying to get the total number of all ordered elements in a success.html file. I can get the order ID and subtotal and want the total number of all orders to be ordered.

I can do this on the cart page, but not on the success page.

+4
source share
1 answer

Try entering the code,

<?php
$order=Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId());//increment_id,like 100000004
$ordered_items = $order->getAllItems();
foreach($ordered_items as $item){
    echo $item->getSku();
    echo "<br />";
    echo $item->getQtyOrdered();
    echo "<br />";
    //ordered qty of item
    echo $item->getName();
    echo "<br />";
    // etc.
} 
?>

To get the total order quantity, use the code below.

$order->getData('total_qty_ordered');
+5
source

All Articles