Magento - get rule from coupon code

前端 未结 3 2036
粉色の甜心
粉色の甜心 2020-12-29 10:55

I have to retrieve the rule associated to a coupon code in order to display in quote the discount percentage of that rule. the simplest way is to calculate directly from quo

3条回答
  •  离开以前
    2020-12-29 11:28

    To load a coupon by code, pass 'code' as 2nd param to load(). Then you can get the proper rule instance by using the rule_id value of your coupon instance:

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

提交回复
热议问题