Magento Checkout:获取小计值而不进行迭代

时间:2010-02-11 15:23:36

标签: magento

<?php
foreach($this->getTotals() as $total)
{
    if ($total->getCode() == 'subtotal')
    {
        $subtotal = $total->getValue();
        break;
    }
}
echo $subtotal;
?>

任何直接获得小计的方法?

5 个答案:

答案 0 :(得分:27)

根据this site

  

您可以通过以下方式获取小计:

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

答案 1 :(得分:12)

尝试使用它:

Mage::getSingleton('checkout/cart')->getQuote()->getSubtotal()

答案 2 :(得分:4)

以下内容应该有效:

$subtotal = $this->getQuote()->getSubtotal();

答案 3 :(得分:0)

    $session= Mage::getSingleton('checkout/session');
    $getotal = Mage::helper('checkout')->getQuote()->getGrandTotal();
    $totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals(); //Total object
    $subtotal = $totals["subtotal"]->getValue();

$ subtotal ”将保留小计的值。

感谢。

答案 4 :(得分:0)