1

I've been searching for days without finding any answers for my conundrum.

I want to make a module that reacts when an item in the cart has changed/updated it's quantity, but I can't find any guide that tells me how to do that. I know several different ways to get all the items in the cart, I know how to get the item added to the cart, but not how to just get the specific item that has been changed in the cart.

I'm using Magento 2, but due to the similarities a guide for how to do it in Magento 1 could still useful to me.

Is there anyway to get the item that has changed/updated in the cart?

1

Magento 2 has model-specific load and save events, similar to Magento 1. I suggest creating an observer on the quote save before event. In your observer, get the items and compare their current quantity to their original quantity stored in orig_data.

This will allow you to know what items have changed. Keep in mind that multiple items may change at once.

If you want the action to only happen on the cart page, as opposed to anywhere else the quote items are updated, then use the request parameters to ensure that the user is on the appropriate page.

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.