0
votes

how do we fetch the coupon code description to the shopping cart. Currently magento shows Coupon code "test001" applied.

I am wondering how do we fetch the description we added in magento backend instead of that message.

display message like "Coupon code "test001" has been applied, you just saved $100 happy shopping."

Magento get coupon description I was looking this but it didn;t worked for me .

2
why that didn't work for you any error put that if not then where you trying to put that code ? - Mahmood Rehman
"app/code/core/Mage/Checkout/controllers/CartController.php" in this file its not printing just blank - govindak

2 Answers

0
votes

Try this code .It works for me

$rule = Mage::getModel('salesrule/rule')->getCollection()
    ->addFieldToFilter('code', '1234');
foreach ($rule as $value) {

    $description = $value->getDescription();
    print_r($description);

}.

I put this code in cart controller under the addAction() function.

0
votes

codes submited by Mahmood Rehman works, even in 1.7.0.2.

change "app/code/core/Mage/Checkout/controllers/CartController.php"

in public function couponPostAction()

look for

      if ($couponCode == $this->_getQuote()->getCouponCode()) {
                $this->_getSession()->addSuccess(
                    $this->__('Coupon code "%s" was applied.', Mage::helper('core')->htmlEscape($couponCode)) . ' '.$description
                );
            }      

change it to

if ($couponCode == $this->_getQuote()->getCouponCode()) {
                $description = '';
                try { 
                   $rule = Mage::getModel('salesrule/rule')->getCollection()
                        ->addFieldToFilter('code', 'YOURCOUPONCODE');
                    foreach ($rule as $value) {
                        $description = $value->getDescription();
                    }                        
                } catch (Exception $e) {
                    Mage::logException($e);
                }
                $this->_getSession()->addSuccess(
                    $this->__('Coupon code "%s" was applied.', Mage::helper('core')->htmlEscape($couponCode)) . ' '.$description
                );

of course this could be improved, but does the job.

Regards,