4

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.

1 Answer 1

3

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

3
  • Thank you for the quick response i will try it and will get back to you with the results. Thanks again
    – Haris
    Commented Jun 29, 2015 at 8:23
  • Thanks for your answer (accepted), it works fine on magento ver 1.9 but i am getting White Screen of Death on mag ver 1.8 when i add product to cart. In apache error log it say, Allowed memory size of 268435456 bytes exhausted (tried to allocate 262668288 bytes)
    – Haris
    Commented Jun 30, 2015 at 6:16
  • Hi, just need to remove $items = $this->_calculator->sortItemsByPriority($items); to get it working on magento ver 1.8. Thanku :)
    – Haris
    Commented Jul 3, 2015 at 9:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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