0

To give a little context, we are using the OrganicInternet Simple Configurable Products module to avoid having configurable products in our cart. All simple products on the site are marked as not visible individually. The problem we have is that a simple product remains in the cart even when it's associated configurable is disabled or removed.

The quote_item for the simple product contains the ID of the configurable product that was added, so the obvious solution to this seems to be to hook into an event use the cpid to check if the configurable product is enabled and remove the item from the quote.

The only problem is, I'm not entirely sure where to hook into. I tried _before_save on the quote, this seems to work, but has the issue that if no items are left in the quote, you end up seeing an empty basket (as opposed to the empty basket message). Any suggestions?

1

In the end the best option seems to be creating an event listener for sales_quote_item_collection_products_after_load to remove the products from the collection. This in turn causes the quote item to be marked for deletion, which in turn updates the database when the quote is saved. As far as I can tell this is how a quote item is removed when a product is disabled.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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