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

Order processing

When processing orders in Episerver commerce, please refer to the namespace EPiServer.Commerce.Order, specifically these classes:

  • EPiServer.Commerce.Order.IOrderGroupExtensions
  • EPiServer.Commerce.Order.IInventoryProcessor
  • EPiServer.Commerce.Order.ILineItemValidator
  • EPiServer.Commerce.Order.IPaymentProcessor
  • EPiServer.Commerce.Order.IPlacedPriceProcessor
  • EPiServer.Commerce.Order.IFulfillmentWarehouseProcessor
  • EPiServer.Commerce.Marketing.IPromotionEngine

All samples below pass the dependencies to the extension methods to be able to easily unit test your applications.

Validation issues

When performing different actions on an IOrderGroup, issues can cause modifications to line items. These warnings and errors are represented in the class EPiServer.Commerce.Order.ValidationIssue. Most processing tasks take a parameter with an Action<ILineItem, ValidationIssue>, which allows the caller to collect this information so a message about the issue can be displayed to the user.

Validate line item

Validating the status of line item is useful to make sure the product is active, within the valid date range, and that the catalog entry is available in the current market.

Update placed price

Updating placed price is useful when a shopper has an item in their cart for an extended period of time. It is wise to check if the product price has changed and, if so, to update the price so the business does not lose money.

Apply discount

Applying discounts will run the promotion engine to evaluate and apply discounts to the IOrderGroup. If certain discounts require coupons, it is important to add coupons to the IOrderForm before running apply discounts.

Process payments

Process payments allow the configured payments to be processed through their respective payment providers.

Update inventory

Update inventory checks that a sufficient inventory quantity exists for the selected shipment warehouse. This method also updates the line item with the available quantity or, if none are available, removes it.

Adjust inventory

Adjusts inventory for each line item and removes it if no inventory exists. This operation is done in sequence for each shipment in an IOrderGroup, or for a specific shipment if the IInventoryProcessor method is called directly.

The behavior changes based on the value of the IOrderGroup's OrderStatus property. If calling the IInventoryProcessor directly, you should pass the status of the shipment's parent IOrderGroup:

  • Completed - permanents the reservation of inventory, decrementing available quantity.
  • Canceled - cancels the reservation of inventory, incrementing available quantity.
  • InProgress || AwaitingExchange - reserves inventory to fulfill the shipment.

In addition, the value of IShipment.OrderShipmentStatus may override the behavior for a specific shipment:

  • Shipped - same behavior as OrderStatus.Completed but is applied regardless of the value of IOrderGroup.OrderStatus.
  • Cancelled - same behavior as OrderStatus.Cancelled but is applied regardless of the value of IOrderGroup.OrderStatus.