This content is archived. See latest version here

Last updated: May 25 2015

EPiServer Commerce provides two order events for integration purposes so actions can be taken during these events. These events are synchronous, Therefore it is important for the actions to be quick, or be done in an asynchronous manner, so the event can return while the action does its work.

Example of how to use events

[ModuleDependency(typeof(EPiServer.Commerce.Initialization.InitializationModule))]
public class OrderEventInitialization : IConfigurableModule
{
    public void Initialize(InitializationEngine context)
    {
        OrderContext.Current.OrderGroupUpdated += Current_OrderGroupUpdated;
        OrderContext.Current.OrderGroupDeleted += Current_OrderGroupUpdated;
    }

    private void Current_OrderGroupUpdated(object sender, OrderGroupEventArgs e)
    {
        Task.Run(()=> DoSomething(sender as OrderGroup, e));
    }

    private void DoSomething(OrderGroup order, OrderGroupEventArgs e)
    {
         
    }
}

Do you have feedback on this documentation? Send an email to documentation@episerver.com. For development-related questions and discussions, refer to our Forums on https://world.episerver.com/forum/