0

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.

0

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;
    }
}
| improve this answer | |
  • when placing this code, the page still loading from last 5mins. – venkata prasad Feb 8 '18 at 9:44
  • Replace OrderPlacebefore class. – Suresh Chikani Feb 8 '18 at 9:45
  • the same name I'm using the file name – venkata prasad Feb 8 '18 at 9:49
  • Open OrderPlacebefore.php file and replace code with my answer code. – Suresh Chikani Feb 8 '18 at 9:51
  • Yes I did that but same still loading – venkata prasad Feb 8 '18 at 10:29

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.