I am trying to know if create shipment option is selected from admin while creating invoice from admin by creating an observer.
I have tried
sales_order_invoice_register
sales_order_invoice_save_after
events .
My observer is :
<?php
namespace Nmaespace\Module\Observer;
class Invoice implements \Magento\Framework\Event\ObserverInterface
{
/**
* Execute observer.
* @param \Magento\Framework\Event\Observer $observer
* @return $this
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
$invoice = $observer->getEvent()->getInvoice();
$do_shipment = $invoice->getData('do_shipment');
echo $do_shipment;exit;
}
}
After all di compile and everything when i try to create an invoice i am getting empty value here .
Can someone please help me how check this.
Best Answer
Try this, In your observer
Hope this helps :)