Question

I created a observer and i need to fetch the zip code of current quote, Below code is for my event.xml

<event name="sales_quote_collect_totals_before">
<observer name="sipl_oda_observer_observer" instance="Sys\Oda\Observer\Observer" />
</event>

Code for Observer.php

$order= $observer->getData('order');
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
Was it helpful?

Solution

First of all, you can not get order object $order from this observer.

This observer only able to give u Quote Object mean Cart object

$this->eventManager->dispatch( 'sales_quote_collect_totals_before', ['quote' => $quote] );

So, At Observer files, you cab get Quote object

$quote = $observer->getEvent()->getQuote();

from this Quote object you can get Cart item details ,billing and shipping address,payments method details etc of a Cart

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top