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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top