Magento get coupon description

让人想犯罪 __ 提交于 2020-01-03 19:18:10

问题


I am trying to retrive the text set in the Magento Coupon Description field to use as part of a validation rule. Does anyone know how to load a coupon price rule using the coupon code and retrieve the associated coupon description text?


回答1:


Under Magento 1.3, you can use this code (not tested as I have no 1.3 within easy reach) :

$rule = Mage::getModel('salesrule/rule')->load($code, 'coupon_code');

if ($rule->getId()) {
    $description = $rule->getDescription();
}



回答2:


I have used in magento 1.9 and below code is working fine for me.

$oCoupon = Mage::getModel('salesrule/coupon')->load($couponCode, 'code');
                $oRule = Mage::getModel('salesrule/rule')->load($oCoupon->getRuleId());
                $message = $oRule->getData();
                $description = $message['description'];

                $this->_getSession()->addError(
                    $this->__($description, Mage::helper('core')->escapeHtml($couponCode))
                );



回答3:


$oCoupon = Mage::getModel('salesrule/coupon')->load($couponCode, 'code');
$oRule = Mage::getModel('salesrule/rule')->load($oCoupon->getRuleId());
var_dump($oRule->getData());

you can refer for same Magento - get rule from coupon code



来源:https://stackoverflow.com/questions/17025974/magento-get-coupon-description

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!