Search code examples
phpmagento

How to get Coupon Discount Amount by Coupon code?


I used the following code to retrieve the coupon code for the current order:

$Coupon_Code = $order->getCouponCode();

It works fine, but I want to get the discount amount for a certain coupon code, using this code:

$Coupon_Code = $order->getCouponCode();
            
$oCoupon = Mage::getModel('salesrule/coupon')->load($Coupon_Code, 'code');
$oRule = Mage::getModel('salesrule/rule')->load($oCoupon->getRuleId());
var_dump($oRule->getData());
$Coupon_Discount =$Coupon_Code['Discount Amount'];
        

Solution

  • You can get the discount amount for a certain coupon code by using this:

    $couponCode = '**YOUR COUPONCODE**';
    $oCoupon = Mage::getModel('salesrule/coupon')->load($couponCode, 'code');
    $oRule = Mage::getModel('salesrule/rule')->load($oCoupon->getRuleId());
    print_r($oRule->getData());exit();
    

    In the response you can get all of the details regarding COUPONCODE.