I am trying to show order details on frontend just like backend enter image description here

Here is my code

$orderData = Mage::getSingleton('sales/order')->loadByIncrementId($incrementId);
$itemCollection = $orderData->getItemsCollection();

foreach($itemsCollection as $_items) {
    echo $_items->getName();
    echo $_items->getStatus();
    echo $_items->getOriginalPrice();
    echo $_items->getPrice();
    echo $_items->getQtyOrdered();
    echo $_items->getSubTotal();
    echo $_items->getTaxAmount();
    echo $_items->getPercent();
    echo $_items->getDiscountAmount();
    echo $_items->getRowTotal();

Apart from Subtotal I am getting Everything I tried this too:

echo $_items->getBaseSubtotal();

But I am still getting null value. Any help will be appreciable


base_subtotal is field of Order table.

it is not field to sales order item table..So you did not get data from $_items->getBaseSubtotal()

In order to get a sales item base total try below code:

  • sir what about getSubtotal() – PRashant PUrohit Jun 29 '16 at 10:11
  • 1
    Prashant, getSubtotal() give u you order 's subtotal in Order placed currency – Amit Bera Jun 29 '16 at 10:26
  • Thanks a lot for the sharing the concept I got confused when I saw the collection using var_dump I thought this sub total is for item row , Your code worked for me – PRashant PUrohit Jun 29 '16 at 10:35
  • @AmitBera I have to give free shipping order over and 1000 and zipcode between 600001 to 600010, i am using webshop matrix rate for shipping method, in this case, shopping cart pricing rule not working free shipping, so i have to plan for do custom PHP code for giving free shipping, My condition how can i give condition like subtotal is equal or greated than 1000 and zipcode 600001 and 600010 in /public_html/app/design/frontend/base/default/template/checkout/cart/shipping.phtml – Gem Oct 3 '18 at 7:26

From order items collections, you can get item's (row's) subtotal OR row_total BUT you CAN NOT get Order's Subtotal. You can iterate through order item's collection and can sum $_items->getSubTotal(); but it's NOT RECOMMENDED.

For Order's subtotal, use :

echo "Subtotal: ".$orderData->getSubtotal();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.