I am trying to get order information to do some tasks, after the order is placed. I tried with the events "checkout_submit_all_after" and also with "sales_order_place_after" but the only event I am able to capture with an observer is "checkout_onepage_controller_success_action". Can anyone help me to know how to get the order information with this event, or how to achieve it with another event. I need one that happens after the "Place" button is pressed.

My "events.xml":

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="checkout_cart_add_product_complete">
    <observer name="add_order_cart" instance="Tracy\ShippingMethod\Observer\AddOrderToCart"/>
<event name="checkout_onepage_controller_success_action">
    <observer name="send_order_tracy" instance="Tracy\ShippingMethod\Observer\SendOrderToTracy"/>
<event name="sales_order_place_after">
    <observer name="send_order_tracy_sales" instance="Tracy\ShippingMethod\Observer\SendOrderToTracyFromSales"/>

My observer class:

class SendOrderToTracy implements \Magento\Framework\Event\ObserverInterface
    public function execute(\Magento\Framework\Event\Observer $observer)
       $writer = new \Zend\Log\Writer\Stream(BP.'/var/log/test.log'); // creates new log file named test.log in var/log folder
       $logger = new \Zend\Log\Logger();
       $logger->info("Aquí caputré el evento: checkout_onepage_controller_success_action."); // this will be print in test.log file

       $order_ids  = $observer->getEvent()->getOrderIds();
       $order_id   = $order_ids[0];
       $myText = (string)$order_id;

  • are you able to get order id ? Oct 17, 2018 at 15:16
  • Hey @NaveedAsim. Yep, I was able to take the order Id, but I can not get the order, :(. Oct 17, 2018 at 15:19

1 Answer 1


try this code to get order details, you can either use directly in your function or can call interface ( \Magento\Sales\Api\Data\OrderInterface ) using constructor.

using object manager this is how you will do it :

$orderFactory = \Magento\Framework\App\ObjectManager::getInstance();
$processOrder = $orderFactory->get('\Magento\Sales\Model\Order')->load($orderId);

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.