4

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.

6
  • for which event want to fire? after click on checkout button? Commented Sep 28, 2016 at 6:17
  • Need to check Before Event while click on "Checkout" Button. Can?
    – Jackson
    Commented Sep 28, 2016 at 6:19
  • 2
    you can try with controller_action_predispatch_checkout_index_index event Commented Sep 28, 2016 at 7:14
  • @Rakesh ok let me check that
    – Jackson
    Commented Sep 28, 2016 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?
    – Jackson
    Commented Sep 28, 2016 at 7:20

1 Answer 1

11

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.

2
  • hi bro it was working fine but now proceed to checkout is not proceeding on next page .. Commented Apr 11, 2017 at 13:47
  • Hi Rakesh Jesadiya.How to get estimate shipping details from controller_action_predispatch_checkout_index_index event? Commented Jul 29, 2019 at 6:47

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.