2

I want to display each promo name and total applied for current quote in checkout/cart , right now i'm able to display the name of each promo like this:

$quote = Mage::getSingleton('checkout/session')->getQuote();
$discountTotal = 0;
$discounts = array();

foreach ($quote->getAllItems() as ){
  if($item->getAppliedRuleIds() == '' || $item->getDiscountAmount() < 1) {
    continue;
  }
  $discountTotal += $item->getDiscountAmount();
  foreach(explode(",",$item->getAppliedRuleIds()) as $ruleId){
      $rule = Mage::getModel('salesrule/rule')->load($ruleId);
      $ruleName = $rule->getName();
      if (!empty($rule->getCouponCode())) {
        $ruleName = $ruleName . ' - <b>' . $rule->getCouponCode() .'</b>';
      }
      if (array_key_exists($ruleName,$discounts)) {
        $discounts[$ruleName] += $item->getDiscountAmount();
      } else $discounts[$ruleName] = $item->getDiscountAmount();
  }
}
return $discounts;

enter image description here

But the total amount for each promo is wrong, how can i get total for each promo applied in my quote

Your Answer

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

Browse other questions tagged or ask your own question.