4

What are the best events to observe? When

  1. A cart is created
  2. Updates a cart
  3. A cart is deleted
14

Below Are the list of Events for cart :

  1. checkout_cart_add_product_complete
  2. checkout_cart_update_item_complete
  3. checkout_cart_product_add_after
  4. checkout_cart_update_items_before
  5. checkout_cart_update_items_after

  6. checkout_cart_save_before

  7. checkout_cart_save_after
  8. checkout_cart_product_update_after

For Use of each refer this url - https://cyrillschumacher.com/magento-2.1-list-of-all-dispatched-events/

| improve this answer | |
  • How would you control if the cart was deleted by the user? – Miguel Jun 15 '17 at 9:45
2

You probably need one of these:

checkout_cart_product_add_after
checkout_cart_update_items_before
checkout_cart_update_items_after
checkout_cart_save_before
checkout_cart_save_after
checkout_cart_product_update_after

Have a look at this.

https://www.mageplaza.com/magento-2-module-development/magento-2-events.html

| improve this answer | |
  • what is the difference between checkout_cart_product_update_after and checkout_cart_update_items_after? – Miguel Jun 15 '17 at 9:50
  • checkout_cart_product_update_after dispatched inside updateItem(params) method, checkout_cart_update_items_after dispatched inside updateItems($data) method. One for single item, one for bulk items in cart. – Toan Nguyen Jul 10 '17 at 7:00
0

If you are using Magento 2.3.3 or newer you should check sales_quote events.

For example sales_quote_remove_item when you want to observe the delete action on cart

| improve this answer | |

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.