Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento Get total ordered items' quantity in success page

Tags:

php

magento

I have looked whole of the google and could not find a working solution for my requirement. Please help.

I am trying to get total quantity of all the ordered items in success.html. I am able to get order id and subtotal and want total qty of all the items ordered.

I can do this in cart page but not on success page.

like image 517
m bab Avatar asked Apr 21 '15 08:04

m bab


1 Answers

Try below 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 total qty of an order,use below code.

$order->getData('total_qty_ordered');
like image 121
Dushyant Joshi Avatar answered Nov 02 '22 12:11

Dushyant Joshi