How to get invoiceId from sales_order_invoice_pay event.

$invoice = $observer->getEvent()->getInvoice();
$invoice->getIncrementId();

Can't get with this code But with sales_order_invoice_save_after event I can get the ID.

Can anyone help me out to get invoiceId from sales_order_invoice_pay

有帮助吗?

解决方案

sales_order_invoice_pay can provide order objects.From that order object, you can get invoices of an order, that can multiple invoices or single invoice.

$order = $observer->getEvent()->getOrder();
$invoiceList = $order->getInvoiceCollection();
if (count($invoiceList->getItems()) > 1) {
    foreach ($invoiceList as $invoice){
        $invoice->getIncrementId();
    }
}
许可以下: CC-BY-SA归因
scroll top