Pergunta

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

Foi útil?

Solução

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();

Outras dicas

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();
Licenciado em: CC-BY-SA com atribuição
Não afiliado a magento.stackexchange
scroll top