<?php
foreach($this->getTotals() as $total)
{
if ($total->getCode() == 'subtotal')
{
$subtotal = $total->getValue();
break;
}
}
echo $subtotal;
?>
任何直接获得小计的方法?
答案 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)