Skip to content

Add checkout_cart_product_add_before event #17830

@peterjaap

Description

@peterjaap

As @markoshust blogged in 2012 (!), there is no checkout_cart_product_add_before event in Magento!

Even though there is a checkout_cart_product_add_after event. Now we're stuck with controller_action_predispatch_checkout_cart_add which of course does not catch all cases since there are multiple (custom) ways to add a product to the cart.

Best option now is to create a plugin, but an event would be nicer.

Preconditions

  1. Magento 2 code

Steps to reproduce

  1. Observe \Magento\Checkout\Model\Cart::addProduct

Expected result

  1. Events checkout_cart_product_add_before and checkout_cart_product_add_after are dispatched.

Actual result

  1. Only checkout_cart_product_add_after event is dispatched.

Metadata

Metadata

Labels

Component: Framework/CodeFixed in 2.3.xThe issue has been fixed in 2.3 release lineIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentReproduced on 2.2.xThe issue has been reproduced on latest 2.2 releaseReproduced on 2.3.xThe issue has been reproduced on latest 2.3 release

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions