I’m writing a small module that will add a product to the cart automatically (based on certain criterias). However if the user subsequently removes that automatic product from the cart I need to know so that I don’t add it again in the current session.
Does the cart object hold anything that can tell me if a product has been removed from the cart already?
Magento doesn’t keep record of which items have been removed, you will have to do that yourself. Start by listening for an event;
app/local/YOURMODULE/etc/config.xml
app/local/YOURMODULE/Model/Observer.php
Create a session class that extends
Mage_Core_Model_Session_Abstractand use it to store the product IDs you collect in the above observer. You can then refer to that session object (called byMage::getSingleton()) to see what products used to be in the cart.