How to Get Total Discount Amount of Coupon Code for All Items in Cart

cartce-1.9.0.1coupondiscount

I'm using Magento 1.9.0.1 and here is the code on which I am working on:

$quote2 = Mage::getSingleton('checkout/session')->getQuote();
foreach ($quote2->getAllItems() as $item){
    $DiscountTotal = $item->getDiscountAmount();
}

This code is giving me the amount discounted with coupon code of the first item in the cart for the current session.

The problem is that this code is giving me the amount discounted only for the first item but not for all items in the cart for the current session.

So I have two questions:

  1. How I can get the total discount amount for all items the cart for the current session?
  2. How I can get the total discount amount for already completed order?

Best Answer

$quote2 = Mage::getSingleton('checkout/session')->getQuote();
$discountTotal = 0;
foreach ($quote2->getAllItems() as $item){
    $discountTotal += $item->getDiscountAmount();
}