Tuesday, February 8, 2022

[FIXED] How to get subtotal from order items collection in magento 1.9.2 community edition

Issue

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.


Solution

From Amit Bera's answer on Magento.SE:

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:

$items->getBaseRowTotal();


Answered By - krishna singh

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.