I'm finding Magento event dispatching is quite a frustrating area. I suppose a lot of that frustration is, as usual, down to the lack of documentation.
I would like my code to be triggered at various stages as a visitor traverses through a site. So I put some debug in Mage::dispatchEvent, and I walked through the site to see what events are fired at each stage. There are a lot!
Two places I am interested in are:
when the visitor had selected a billing address and moved on to the next stage of the checkout process.
when a user successfully places an order
For the billing address one, the events that I saw being fired that look relevant are:
controller_action_predispatch_checkout_onepage_saveBilling
controller_action_postdispatch_checkout_onepage_saveBilling
The 'pre' and 'post' suggested to me that there is actually a 'checkout_onepage_saveBilling' event, but there isn't, so my first question is why the 'pre' and 'post'?
For the successful order, the events that look good are:
checkout_onepage_controller_success_action
checkout_multishipping_controller_success_action
My second question is will these events be fired for all payment methods? For example, if using Google Checkout, or PayPal (standard redirect), will the event fire, and at what point? When returning to the site from PayPal? If so that would beg the question what if the user does not return after completing payment.
Thanks for any help.
Sadly, I've noticed that checkout_submit_all_after
does not fire for Paypal Express orders.
Short of modifying the Paypal models to add this (or perhaps hooking into events they may fire - I haven't checked on that yet), I think checkout_onepage_controller_success_action
may really be the only event you can absolutely count on for every type of order.
The predispatch event will fire before the action has been called, the postdispatch event will fire after the action has been completed. So if you need to know what the result of the action was, you should use the postdispatch event.
For successful orders, checkout the checkout_submit_all_after event.
If you haven't seen it, https://www.nicksays.co.uk/magento-events-cheat-sheet-1-9/, is a handy reference for Magento events.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With