3

May be I need to create Event Observer. I would like to check Product's Type Condition & Display Message Accordingly on Shopping Cart Page.

  <event name="controller_action_predispatch_XXX_XX_XX">
  <observer name="checkcout_page" instance="Custom\Module\Observer\CheckShoppingCartObserver" />
  </event>

http://www.advancedcheckout.com/blog/list-event-magento2.html/

https://cyrillschumacher.com/magento2-list-of-all-dispatched-events/

It's not giving event information when it's gonna execute on, on which place/page?

What will be method i need use instead of XXX.

  • for which event want to fire? after click on checkout button? – Rakesh Jesadiya Sep 28 '16 at 6:17
  • Need to check Before Event while click on "Checkout" Button. Can? – Ankit Shah Sep 28 '16 at 6:19
  • 1
    you can try with controller_action_predispatch_checkout_index_index event – Rakesh Jesadiya Sep 28 '16 at 7:14
  • @Rakesh ok let me check that – Ankit Shah Sep 28 '16 at 7:16
  • @Rakesh It works :). Must say Excellent Knowledge you have. I'm just a beginner. There will be no case like pre & post dispatch right? – Ankit Shah Sep 28 '16 at 7:20
5

You have to just use controller_action_predispatch_checkout_index_index action to check before checkout index page is load.

 <event name="controller_action_predispatch_checkout_index_index">
    <observer name="checkcout_page" instance="Custom\Module\Observer\CheckShoppingCartObserver" />
 </event>

If you want to fire event before any action is called you have to use controller_action_predispatch_XX_XX_XX

If you want to fire event after any action is called you have to use action event controller_action_postdispatch_XX_XX_XX

In above section XX_XX_XX is handlename/action of page. You can call any action in pre and post dispatch event for each page.

In your case checkout_index_index handler is used.

Just for example, If you want to do something before checkout cart page is load you have to use event controller_action_predispatch_checkout_cart_index

If you want to do something after checkout cart page is loaded, you need to define controller_action_postdispatch_checkout_cart_index action and set your logic in observer file.

  • hi bro it was working fine but now proceed to checkout is not proceeding on next page .. – Sarvesh Tiwari Apr 11 '17 at 13:47

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.