2

In my ajax custom cart after applying a coupon code, adding a free gift product to cart programmatically. That new product is not detected for shopping rule validation. But the product is available in quote table without having applied rule ids.

But in default cart after saving the new product to cart functions like collectTotals() is called which detects the new product.

Please advise me how to fix this or how to trigger checkout_cart_index event programmatically.

2018-06-05T11:51:25+00:00 DEBUG (7): DEFAULT CART:  FREE GIFT ADDED TO CART
2018-06-05T11:51:30+00:00 DEBUG (7): Event Triggered: checkout_cart_index
2018-06-05T11:51:30+00:00 DEBUG (7): predispatch() called....
2018-06-05T11:51:30+00:00 DEBUG (7): _getCart() called...
2018-06-05T11:51:30+00:00 DEBUG (7): _getCart() called...
2018-06-05T11:51:30+00:00 DEBUG (7): save()...called in Cart.php
2018-06-05T11:51:31+00:00 DEBUG (7): called by Mage_Checkout_CartController :: indexAction

Using the below code:

$cart->addProduct($product,$request);
$cart->save();
$this->_getQuote()->setTotalsCollectedFlag(false)->collectTotals()->save();

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.