Magento – PHP How to i get the Coupon code discount amount for the current session order

PHP

Guys i'm trying to find a code that will give me the discount amount for the current session order when i discount code is used.

Here is what i have right now but it is not working:

        $coupon = Mage::getModel('salesrule/rule');
        $couponCollection = $coupon->getCollection();
        foreach($couponCollection as $c){
            $CouponDiscount = $c->getDiscountAmount();
        }
        echo $CouponDiscount;

How can i get the amount of the discount used in the current session order ?

Thanks in advance!

Best Answer

Hi you can get a order discount amount from order field discount_amount

like this:

$order=Mage::getModel('sales/order')->load($orderid)
$order->getDiscountAmount()

for Current checkout session then try it

$totalItemsInCart = Mage::helper('checkout/cart')->getItemsCount(); //total items in cart
$totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals(); //Total object
$subtotal = round($totals["subtotal"]->getValue()); //Subtotal value
$grandtotal = round($totals["grand_total"]->getValue()); //Grandtotal value
if(isset($totals['discount'])) {
    $discount = round($totals['discount']->getValue()); //Discount value if applied
} else {
    $discount = '';
}
Related Topic