Change order status before or after order finalized
How can we change the order status in the tea commerce backend when an order is finalized or before finalized?
I need to change the status by code when an order is completed.
Probably your best bet is to hook into the Finalizing event to be notified when an order is just about to be finalized. The sender argument for the event is the order in question, so within the handler, you should be able to set the orders OrderStatusId from there.
If you do set it within the finalizing event, this is before the order is saved so you shouldn't need to call .Save() yourself, however as the finalizing event is the last event to run, setting the order status ID from within the finalizing event, won't fire the OrderStatusChanging event should that be something you are relying on. The OrderStatusChanged should still fire though, post persistence, so it may be you can use that instead if you are using it.
Change order status before or after order finalized
How can we change the order status in the tea commerce backend when an order is finalized or before finalized? I need to change the status by code when an order is completed.
Hi Vineeth,
Probably your best bet is to hook into the
Finalizing
event to be notified when an order is just about to be finalized. The sender argument for the event is the order in question, so within the handler, you should be able to set the ordersOrderStatusId
from there.If you do set it within the finalizing event, this is before the order is saved so you shouldn't need to call
.Save()
yourself, however as the finalizing event is the last event to run, setting the order status ID from within the finalizing event, won't fire theOrderStatusChanging
event should that be something you are relying on. TheOrderStatusChanged
should still fire though, post persistence, so it may be you can use that instead if you are using it.Thanks, Matt :)
is working on a reply...