I want to delete items from cart while adding new products. I am observing : checkout_cart_add_product_complete event for this. My code is following:
<checkout_cart_add_product_complete> <observers> <secodaryproduct> <type>singleton</type> <class>secodaryproduct/observer</class> <method>checkoutCartAddProductAddComplete</method> </secodaryproduct> </observers </checkout_cart_add_product_complete>
And for deleting products:
$cartHelper = Mage::helper('checkout/cart'); $cartHelper->getCart()->removeItem($product['item_id'])->save();
When i call this code without observer then this works fine and delete required items. But if i use this using observer then items not deleting from cart. I have also put the output in log file and item ids are printing correctly but my items are not deleting from cart. Please help.
To remove the item before you add new a new item in cart, you have to use this event: