I am basically trying to implement the scenario where certain special products can only be brought once in customer's lifetime. So need to make sure that if they are added again after being purchased in past, they are swapped with another regular product.
All this is working on checkout_cart_product_add_after
except the problem that the product which has been just added doesn't have Item ID assigned to it yet. My understanding is that the item ID hasn't been assigned to it since I am in middle of the saving process.
This is what it looks like inside the observer:
How can I remove an item at this point of execution without itemID being available? I studied Cart & Quote classes in Core and I don't see any way of removing item without knowing its ItemID since its basically just an element of array.
Should I be using another event to do this where this is available? My only concern is that I need to implement the whole swapping in place, not just removed the just added item in cart. So need a combination that works for both (removing the just added product + add more as its replacement).
Any pointers?