How to Get Order Data From Magento 2 “sales_order_place_after” Event

How to Get Order Data From Magento 2 "sales_order_place_after" Event

Admin would want to use order data after an order is placed for many purposes. Admin may want the order data to send to shipping carriers for order delivery or send an SMS to the customer for acknowledging their order or calculate taxes based on product, location, and other such factors. To retrieve the order data, one needs to use Events and Observers in Magento 2.

Events in Magento 2 are dispatched based on an action performed and it passes data to the observer. Observers are Magento classes that are executed when an event is dispatched. Here, we will make use of this concept to get order data from Magento 2 “sales_order_place_after” event.


Method to Get Order Data From Magento 2 “sales_order_place_after” Event

Step 1: Create events.xml file at app/code/Vendor/Extension/etc/

Step 2:  Create Orderplaceafter.php at app/code/Vendor/Extension/Observer/

Follow these steps and get order data from Magento 2 “sales_order_place_after” event to use it either for better administration or enhance the customer experience!

For a similar solution in Magento 1, check here.

Doubts will be entertained in the comments section below. Also, let me know how have you used this order data for the betterment.

Rate the post with 5 stars if you like it!

Happy Coding 🙂

Get Weekly Updates

Never miss Magento tips, tricks, tutorials, and news.

Thank you for subscribing.

Something went wrong.

(based on 28 Reviews)

Sanjay is a co-founder at Meetanshi. He is a Certified Magento Developer who loves creating Magento E-commerce solutions. Owing to his contributions in Magento Forums and posting solutions, he is among the top 50 contributors of the Magento community in 2019. When he is not engrossed with anything related to Magento, he loves to play cricket.

14 comments On How to Get Order Data From Magento 2 “sales_order_place_after” Event

Leave a reply:

Your email address will not be published.