What is the actual difference between these two events?

Is it simply that OrderEvents::ORDER_ITEM_CREATE is triggered for order items added in any way (like both from front end cart and from back end admin UI), and CartEvents::CART_ENTITY_ADD is only triggered when an item is added to a cart?

I understand that order items could be things that are not purchasable entities etc so there is a difference there, but essentially OrderEvents::ORDER_ITEM_CREATE will fire anytime that artEvents::CART_ENTITY_ADD does?

Are there other important differences?

I have some code in the CartEvents::CART_ENTITY_ADD event doing a bunch of stuff and due to a new request I now need to run the code when an order item is added in the Admin UI and not just when an item is added to the cart.

Im thinking OrderEvents::ORDER_ITEM_CREATE is the correct event to traget, with some sort of condition to only fire if the order is enetered from the admin UI.

However Im now thinking that I shouldnt be using CartEvents::CART_ENTITY_ADD at all if OrderEvents::ORDER_ITEM_CREATE is fired in all cases (both when an item is added to a cart and also when added from admin UI)?


Your Answer

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

Browse other questions tagged or ask your own question.