3

I want to display the total price for each product (by id) in the cart.

qty | single price | total
2   |      $ 2.00  | $  4.00 <-- that's what i need
3   |      $ 5.00  | $ 15.00
    |  Subtotals:  | $ 19.00 <-- that's what i get with the code below

$totals = Mage::getSingleton("checkout/cart")->getQuote()->getTotals();
$subtotal = $totals["subtotal"]->getValue();
echo Mage::helper('checkout')->formatPrice($subtotal);

Any help is welcome.

Toto
  • 89,455
  • 62
  • 89
  • 125
ThreeCheeseHigh
  • 1,429
  • 5
  • 22
  • 40

1 Answers1

6

you can use:

$productId = 5;//put here the product id you want the price
$quote = Mage::getSingleton('checkout/session')->getQuote();
$items = $quote->getAllItems();
foreach ($items as $item) {
    if ($item->getProductId() == $productId) {
        $priceInclVat = $item->getRowTotalInclTax();
    }
}
OSdave
  • 8,538
  • 7
  • 45
  • 60