Adding Additional Order Statuses

Follow

NOTE: This article only applies to Active Commerce versions before 3.2. Adding an order state is simplified in more recent versions.

It's easy to add any number of additional order statuses in Active Commerce.

1. Add the item in Sitecore. Under Webshop Business Settings, right-click "Order Status", Insert "Order Status". Important: Leave the "Code" name the same as the item name.

2. Create the corresponding status class. Inherit from Sitecore.Ecommerce.Orders.Statuses.OrderStatusBase. Important: the class name must match the "Code" field value and the item name. You can add any additional logic to the Process method, which is invoked when the status is set using the order pipeline or manually in Sitecore admin.

class Shipped : Sitecore.Ecommerce.Orders.Statuses.OrderStatusBase
{
    protected override void Process<T>(T order)
    {
        // Do nothing. 
    }
}

3. Register with Unity. Note the name used here must match the "Code" field value.

container.RegisterType(typeof(Sitecore.Ecommerce.DomainModel.Orders.OrderStatus), typeof(Shipped), "Shipped");

That's it! You can now use the status just as you would the other statuses - in the order pipeline, order manager, code, etc. E.g.

var shippedStatus = Sitecore.Ecommerce.Context.Entity.Resolve("Shipped");

 

Have more questions? Submit a request

Comments