List of all events in Magento 2.

Magento 2 Comes with many events by default in the core module. You can use any required events from Core module to accomplish your requirement. You can also create your own custom event to accomplish your task.

There are many core events comes with Magento 2 native. You can use events in events.xml and create observer.php file to do specific action for an event. Continue reading “List of all events in Magento 2.”

Different types of Cancel events for Orders in Magento 2

There are many events are available in Native Magento 2 but some of the difficult events of cancel action of payment, invoice or order are as below,

1. order_cancel_after

This event is used after order canceled. If you want to do something after an order is canceled you can use this event.
Check file, vendor/magento/module-sales/Model/Order.php at cancel() function.

2. sales_order_invoice_cancel

Allows you to cancel the order invoice when you canceled the order.
Check event called at, file, vendor/magento/module-sales/Model/Order/Invoice.php at cancel() function.

3. sales_order_payment_cancel_invoice

Allows you to cancel the order invoice when you canceled the order.
Check event called at, file, vendor/magento/module-sales/Model/Order/Invoice.php at cancel() function.

4. sales_order_payment_cancel_creditmemo

Event defined under vendor/magento/module-sales/Model/Order/Payment.php using cancelCreditmemo() function but this function is not called at any file. Might be used in future developments. This event contains payment and specified creditmemo object.

5.sales_order_payment_cancel_invoice

Cancel specified invoice from order and update self-total from order invoice.
Event defined under vendor/magento/module-sales/Model/Order/Payment.php

This event contains payment and invoice object.

6. sales_order_creditmemo_cancel

When you want to refund from a specific order or specific item from order,
Your best suitable event is, sales_order_creditmemo_cancel