3

我想显示购物车中每种产品的总价格(按 id)。

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

欢迎任何帮助。

4

1 回答 1

6

您可以使用:

$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();
    }
}
于 2011-11-11T09:38:57.043 回答