Hide menu Last updated: Oct 24 2016
Area: Episerver Commerce Applies to versions: 10 and higher
Other versions:

Order manipulation

This topic describes how to create, load, save and delete orders in Episerver Commerce.

How it works

When manipulating orders in Episerver Commerce, refer to the namespace EPiServer.Commerce.Order, specifically the classes EPiServer.Commerce.Order.IOrderRepository, EPiServer.Commerce.Order.IOrderRepositoryExtensions, EPiServer.Commerce.Order.IOrderGroupExtensions, and EPiServer.Commerce.Order.IOrderGroupFactory.

Creating orders

When creating orders using the default implementation of IOrderGroupFactory, there is always an IOrderForm in the Forms collection. There is also always an IShipment on the Shipments collection of the IForm. If you create a custom IOrderGroupFactory, assume you need this as well.

Loading orders

Saving orders

Deleting orders

var orderRepository = ServiceLocator.Current.GetInstance<IOrderRepository>();

Working with order forms

Working with shipments

Working with payments

Working with line items

Working with addresses

Working with notes


The IOrderRepository should be able to load all orders of a given type (Cart/PurchaseOrder/whatever) created since/between/before dates - regardless of user. Every function in the order repository now requires either exact order IDs or a user context. For reporting, batch jobs etc. this makes things unnecessarily complicated, and forces us to use the OrderContext class, which is a true pain.

We hear you. We already have a plan to add search support for the new abstraction APIs in our backlog - but it'll not happen anytime soon.