1

I created an events.xml at /app/code/Test/Customer/etc

    <?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_submit_before">
      <observer name="Test_Customer_sales_order_place_before" instance="Test\Customer\Observer\OrderPlacebefore"/>
   </event>
</config>

Created the OrderPlacebefore.php like /app/code/Test/Customer/Observer

 <?php namespace Redington\CustomerAddress\Observer;

use Magento\Framework\Event\ObserverInterface;

class OrderPlacebefore implements ObserverInterface
{
    /**
     * @param Observer $observer
     * @return void
     */
    public function execute(\Magento\Framework\Event\Observer $observer)
    {   
    echo "<pre>";
        print_r($this->_request->getPost());
        exit;

       $quote = $observer->getQuote();

    }
}

I didn't get anything here. But I need to get all data of order like product details, totals and customer details.

Anyone, please help me.

1 Answer 1

3

You can check blow code for get Order Data.

<?php namespace Redington\CustomerAddress\Observer;

use Magento\Framework\Event\ObserverInterface;

class OrderPlacebefore implements ObserverInterface
{
    /**
     * @param Observer $observer
     * @return void
     */
    public function execute(\Magento\Framework\Event\Observer $observer)
    {   
        echo "<pre>";
        print_r($observer->getOrder()->getData());
        exit;
    }
}
8
  • when placing this code, the page still loading from last 5mins. Commented Feb 8, 2018 at 9:44
  • Replace OrderPlacebefore class. Commented Feb 8, 2018 at 9:45
  • the same name I'm using the file name Commented Feb 8, 2018 at 9:49
  • Open OrderPlacebefore.php file and replace code with my answer code. Commented Feb 8, 2018 at 9:51
  • Yes I did that but same still loading Commented Feb 8, 2018 at 10:29

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.