Question

I have a number of coupon codes which i want to apply to the cart programmatically.

I have done it like this:

foreach ($coupons as $coupon) //$coupons array of coupon codes
{
    Mage::getSingleton('checkout/cart')
        ->getQuote()
        ->setCouponCode($coupon)
        ->collectTotals()
        ->save();
}

Now what happens is that if the first coupon is valid, it got applied, but after that

  • if the second coupon is valid, it got replaced (first removed, second applied).
  • if the second coupon is not valid it removes the discount applied by the first coupon too.

Now I need help to tackle the situation as how to be able to apply both coupon/rules/discounts if valid (if possible applying two coupon codes)? or not apply coupon code if not valid so that the coupon applied before doesn't got removed.

Was it helpful?

Solution

As per as magento system,you cannot apply multiple coupon on a cart.

If you want then need to use

3rd partly extension like amasty

Or

you can use this answer:

Magento Multiple coupon apply on cart

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top