Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more

K Khan
Feb 1, 2016
  2818
(3 votes)

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.

Feb 01, 2016

Comments

Please login to comment.
Latest blogs
Save The Date - London 2025 Summer Meetup

Following last years very succesful meetup in London July 2024 https://world.optimizely.com/blogs/scott-reed/dates/2024/7/optimizely-london-dev-mee...

Scott Reed | Mar 25, 2025

Revalidate Page in Next.js after Publishing Content in Headless Optimizely PaaS CMS.

Headless CMS implementations are becoming increasingly popular. In this approach, the CMS and the front-end application are decoupled and can use...

Tomek Juranek | Mar 25, 2025

Getting 404 when expecting 401

A short story about the mysterious behavior of an API in headless architecture.

Damian Smutek | Mar 25, 2025 |

A Free Course for Building Headless Applications with Next.js and Optimizely SaaS CMS

I am excited to announce the transformation of Optimizely Headless CMS webinar into a comprehensive, completely free self-paced course that's...

Szymon Uryga | Mar 24, 2025