I have added one field "Special instructions" (textarea) in mini cart which I want to get saved in order details when customer put the order.

In which observer can I get the value of this field? and how can I save it to order?


First, to add custom field in quote and order table and save your data into quote table.

after creating file Vendor\Extension\etc\events.xml

<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="sales_model_service_quote_submit_before">
        <observer name="custome" instance="Vendor\Extension\Observer\Custome"/>

after creating another file Vendor\Extension\Observer\Custome.php

namespace Vendor\Extension\Observer;

use Magento\Framework\Event\Observer as EventObserver;
use Magento\Framework\Event\ObserverInterface;

class Customeimplements ObserverInterface
    protected $_objectManager;

    public function __construct( \Magento\Framework\ObjectManagerInterface $objectmanager )
        $this->_objectManager = $objectmanager;

    public function execute( EventObserver $observer )
        $order = $observer->getOrder();
        $quoteRepository = $this->_objectManager->create('Magento\Quote\Model\QuoteRepository');
        /** @var \Magento\Quote\Model\Quote $quote */
        $quote = $quoteRepository->get($order->getQuoteId());
        return $this;

This code working for me. Happy Coding..

  • Please tell me my solution is working or not. – Vishal Baraiya Oct 5 at 14:50

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.