How can I get discount amount and grand total amount in mini cart ? (Magento 1.9)
-
13-12-2019 - |
Question
I would like to display discount amount and grand total (including discount) in mini cart with Magento 1.9 instead of sub total.
I didn't find out how to display discount (cart price rule without coupon)
Following this topic : How do I get the discount amount in the minicart for 1.9?
I have been able to display the grand total including the discount... but it is not working for not logged in users.
Any idea ?
Solution
You have to load the quote first:
<?php
$quote = Mage::getModel('checkout/session')->getQuote();
$quoteData = $quote->getData();
$grandTotal = $quoteData['grand_total'];
?>
Then simply replace $this->getSubtotal()
with $grandTotal
.
To get the actual discount amount, you can use this:
$discountTotal = 0;
foreach ($quote->getAllItems() as $item){
$discountTotal += $item->getDiscountAmount();
}
OTHER TIPS
if you use 'quote', you can use this code
$this->getData('grand_total');
In other case use
$quote->getData('grand_total');
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange