I'm currently using this snippet to show the cart totals in the topcart of my Magento shop. My problem is that it's not always updating when products is put in cart, it's just showing 0$, especially configurable products. But when a second product is put in the cart, it's working again.
Am I missing something, should there be a "check" of some kind before this piece of code?
<?php echo Mage::helper('checkout')->formatPrice($this->getSubtotal()) ?>
You can also try following code it works for me
<?php echo Mage::helper('checkout/cart')->getQuote()->getSubtotal() ?>
Make sure your top cart block is extending a relevant block type such as Mage_Checkout_Block_Cart_Sidebar
. If you do, you will have access to useful functionality that will save you rewriting unnecessary code.
For example, if you extend Mage_Checkout_Block_Cart_Sidebar
- you can call getSubtotal()
An alternative would be to use the following:
Mage::getSingleton('checkout/session')->getQuote()->getSubtotal();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With