I'm trying to get an Event after canceling Order now for COD or Pending Orders order_cancel_after
Event is working fine but for Online Payment or Processing Orders same Event is not working I've tried sales_order_payment_cancel_invoice
Event but same that event didnt work.. Now I want to know which Event Triggers on canceling Processing Order. Thanks
2 Answers
As i've seen there's multiple events for the order cancel,
- order_cancel_after
- sales_order_invoice_cancel
- sales_order_payment_cancel_invoice
- sales_order_payment_cancel_creditmemo
- sales_order_payment_cancel_invoice
- sales_order_creditmemo_cancel
If none of those fits you i think you should use the sales_order_save_after event, and check if the new order status differs from the old order status and then do your business logic,
sales_order_save_after and sales_order_state_change_before
on those 2 event's you can go check the new status of the order.
There's this one event: sales_order_save_after
, it triggers a lot!
You can add restriction to your observer to prevent it running too many times (such as check if status is cancel)