Cancel Order Notes
There are few considerations for allowing customers to cancel their orders if those have not been processed. It is up to the business when they allow the customer to cancel the order after placing an order, depending on the complexity of their fulfilment system and payment strategy. If EPiServer commerce site is tracking the inventories those should be restored and if some payment has been taken that will also require a return.
OrderStatusManager class contains some helpful functions to achieve this.
purchaseOrder = OrderStatusManager.CancelOrder(purchaseOrder);
purchaseOrder.AcceptChanges();
OrderStatusManager.CancelOrder does two things.
- Update the Order Status to OrderStatus.Cancelled.
- Run the work flow "RecalculatePurchaseOrderWorkflow".
There are following activities involved in "RecalculatePurchaseOrderWorkflow".
ValidateLineItemsActivity
GetFulfillmentWarehouseActivity
CheckInstoreInventoryActivity
CheckInventoryActivity
AdjustInventoryActivity
ProcessShipmentsActivity
RemoveDiscountsActivity
CalculateTotalsActivity
CalculateDiscountsActivity
CalculateTotalsActivity
CalculateTaxActivity
CalculateTotalsActivity
CalculatePurchaseOrderStatusActivity
This work flow will adjust the inventory of the site (if tracking) but it does not process payments. To process payments (if required), either we can write your own workflow like as "RecalculatePurchaseOrderWorkflow" or can process the refunds during cancellation.
Comments