MotionGrafika
MotionGrafika

Reputation: 1131

Magento Checkout : Get Subtotal Value without iterating

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

Any way to get subtotal directly ?

Upvotes: 11

Views: 28599

Answers (5)

jruzafa
jruzafa

Reputation: 4276

Subtotal cart with taxes:

url: http://niravkadiya.wordpress.com/2012/08/28/sub-total-of-cart-including-tax-without-shipping/

It work me!!

Upvotes: 0

Josh
Josh

Reputation: 11070

According to this site:

You can get the subtotal with:

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

Upvotes: 27

Chiragit007
Chiragit007

Reputation: 1646

    $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" will hold the value of subtotal .

Thanks.

Upvotes: 0

Roman Snitko
Roman Snitko

Reputation: 3655

Try to use this:

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

Upvotes: 12

Chris Norton
Chris Norton

Reputation: 807

The following should work:

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

Upvotes: 4

Related Questions