2011-11-11 6 views
3

カート内の各製品の合計金額(ID別)を表示したいとします。Magento - カート内の単一商品の小計を取得するには?

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

何か援助を歓迎します。

使用できる

答えて

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(); 
    } 
} 
+1

それです!どうもありがとうございました :-) – tecmec

関連する問題