0

Magento version is 2.3.2 I use the sales_order_invoice_register event to send the invoice id to the third party API when create the invoice. My code in the observer is :

$invoice = $observer->getEvent()->getInvoice();
$orderId = $invoice->getOrderId();`
$invoiceNumber = $invoice->getIncrementId();

I Got the order id but Invoice id I got blank. Does anyone have an idea how to get invoice id?

0

Please try with below code :

$invoice = $observer->getEvent()->getInvoice();
$invoice_id = $invoice->getData('increment_id');

I hope its work for you.

  • Please check before post the answer. It's not working. – Krunal Pandya Jul 11 '19 at 6:41
  • you want invoice id ? – Anas Mansuri Jul 11 '19 at 6:42
  • Yes, invoice id. – Krunal Pandya Jul 11 '19 at 6:43
  • than try with $invoice->getData(); – Anas Mansuri Jul 11 '19 at 6:44
  • I tried that but Fatal error: Out of memory – Krunal Pandya Jul 11 '19 at 6:46

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.