Question

How can i get total value in cart without flat rate?

That means by using this code:

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

i got each products sub total.

So i used this code:

$subtotal = $this->helper('checkout')->formatPrice(Mage::getSingleton('checkout/cart')->getQuote()->getGrandTotal()); 

now i got the total value that included the flat-rate also.

for example:

here i got 35 as total but this include 20 product price + 15 flat-rate.

So i want to get only the total of all products price in carts.

How can i get this?

Was it helpful?

Solution

you want to get the subtotal then

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

don't be afraid to use xdebug and debugging sessions within your IDE to observe what values the variables have inside objects. Simplest way to see what you need is to dump variables to display like

print_r(Mage::getSingleton('checkout/cart')->getQuote()->getData()); 

and just see which variable has the value you need.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top