5

What are the best events to observe? When

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

3 Answers 3

18

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/

2
  • How would you control if the cart was deleted by the user?
    – Miguel
    Commented Jun 15, 2017 at 9:45
  • 1
    Is there a event for when the cart loads?
    – Black
    Commented Nov 20, 2020 at 8: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

3
  • what is the difference between checkout_cart_product_update_after and checkout_cart_update_items_after?
    – Miguel
    Commented Jun 15, 2017 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. Commented Jul 10, 2017 at 7:00
  • is there any event for cart viewed? Commented Oct 29, 2020 at 9:30
1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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