1

Having multiple promotions (or discounts) applied for shopping carts, how to get such promotions so I can display them in view?

Update: I want to get each. NOT the total. This is so I can display the labels of each promotions/discounts for the cart. Such as:

Sub Total: 100.00
Discounts:
   First Purchase: -10 (10%),
   Employee Discount: 5 (5%)
Shipping Fee: 20.00
Grand Total: 105
  • do u want the total discount amount or the shopping cart rules applied ? – Manashvi Birla Jul 1 '16 at 10:32
  • I want to get to shopping cart rules applied as list not the totals. – doncadavona Jul 1 '16 at 10:42
3
$appliedRuleIds = Mage::getSingleton('checkout/session')->getQuote()->getAppliedRuleIds();

This will give you the ids of the rules applied to the quote separated by comma.
you can turn them into an array like this:

$appliedRuleIds = explode(',', $appliedRuleIds);

if you want to get the rules applied as objects you can do this:

$rules =  Mage::getModel('salesrule/rule')->getCollection()->addFieldToFilter('rule_id' , array('in' => $appliedRuleIds));

foreach ($rules as $rule) {
    //do something with $rule
}
| improve this answer | |
  • Thanks, I'm now trying this out. I'll let you if this works. – doncadavona Jul 1 '16 at 10:54
  • This works. I'm getting the IDs of the applied rules. Now how do I get the name/label of the rule? Dumping the $rule returns too much data and causes the page to hang. – doncadavona Jul 4 '16 at 2:05
  • Got it! To get the rule label or name: $rule->name – doncadavona Jul 4 '16 at 2:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.