In this article, we will review and compare the order workflows between Sitecore Experience Commerce and OrderCloud to facilitate developers looking to transition from XC to OrderCloud as well as identify a path for migration of existing XC solutions to OrderCloud. We will also review minions from XC and how this these processes can be brought over into OrderCloud to facilitate order workflow automation.
We will look at a high-level comparison of architecture, functionality, and data models, where applicable, with greater focus on transitioning from Sitecore Experience Commerce, meaning identifying a close path to parity in OrderCloud, using the Habitat catalog and SXA Storefront.
In XC, the default order workflow demonstrates the capabilities of post-order placement processing where order status transitions are achieved through manual intervention or automated processes (minions). It is intended to be extended and customised to cater for the unique business requirements of each project.
While figure 1 represents the default order workflow, XC can be customised to create or remove order statuses, and create or remove the triggers that transition an order between statuses, e.g. manual intervention via business users (customer service representatives) or automated processes such as minions.
To provide clarity regarding each order status, XC’s definitions are:
- Pending: Initial order state – order paid, no fulfillment.
- OnHold: Prevents order from being progressed by minions. Customer service representatives may modify, line items, payments, shipments, etc.
- WaitingForAvailability: One or more items in the order are not available. This status is expected for items on backorder or preorder.
- Released: Intended status for indicating the order passed validation and is ready for shipping. It is also typically used in customisations to the workflow to indicate the order has been exported to an external order management system (OMS).
- Problem: An order that has an unexpected status when processed by minions. Manual intervention by customer service representatives is available to transition the order back into a state to be picked up my the minions again, however this typically indicates a bug within custom implementations, which requires developer intervention.
- Completed: Order has been shipped, has had entitlements generated, and has nothing left to process. Complete orders are eligible for the return mechandise authorisation (RMA) processes.
- Cancelled: Order has been cancelled and can no longer be processed by minions or customer service representatives.
In OrderCloud, the order status workflow differs to XC’s in that order submission can include an approval process, which is typically a B2B order scenario, while the post-order placement workflow for order status transitions is minimal, as per figure 2.
The workflow is more rigid in that order statuses cannot be introduced, modified or removed, while the interactions with orders in a given status is also dictated by the platform, however we will address below in Custom Order Status in OrderCloud as to how we can still achieve a customised order workflow on top of the platform.
OrderCloud’s order status definitions are:
- Unsubmitted: Created but has not yet been submitted.
- Open: Submitted but not yet fulfilled.
- AwaitingApproval: On hold awaiting approval.
- Declined: Submitted but has been declined.
- Completed: Submitted and all the line items on the order have been shipped.
- Canceled: Order can no longer be submitted.
Removing the order statuses for approval and the cart equivalent “Unsubmitted” status, we see that OrderCloud simply transitions between
Custom Order Status in OrderCloud
To achieve an XC equivalent order workflow in OrderCloud, the missing order statuses may be introduced under OrderCloud’s
Open status, using
xp to represent the status as psuedo-sub-status. Typically, this would be achieved by PATCHing the order’s
xp, using either middleware as a proxy to support wrap OrderCloud API endpoints with custom logic, or have middleware perform validation via pre-hook webhooks to prevent invalid status transitions.
There is no restriction in modifying the workflow or introducing new statuses via
xp, only considerations for ensuring that the workflow transitions from end-to-end as intended.
Transaction and Payment Status
We previously have covered the payment concepts between XC and OrderCloud in Tax and Payments, but what we didn’t cover was the statuses that belong to these entities and how they can be utilised in the SXA storefront.
For Sitecore Experience Commerce, the federated payment components have a
TransactionStatus property, which is intended on tracking the raw statuses specific to the payment provider. They are typically used only for transparency and reconciliation purposes, rather than driving business logic in XC.
Sales activities have a
PaymentStatus property, which also is intended on tracking the transaction status in a more agnostic fashion by reducing payment provider statuses to more generic status buckets, which can then be used to influence business logic. In Order Workflow, figure 1 shows that the payment status affecting the order status, namely by placing an order into a problem state where the payment status is set as Problem.
Figure 6 and 7 shows the workflows for payment sales activities in XC, which modifies existing sales activity for subsequent transactions, hence representing as transitions, however this is commonly customised to create a separate sales activity per transition for a complete historical view of events and reconciliation reporting.
Translating XC’s payments over to OrderCloud payments resources, we see that transactions have the
ResultCode property, which could be considered the equivalent to XC’s payment status, while XC’s transaction status could be stored on the payment’s
xp. Looking at the payments resource in OrderCloud however we see that the intended architecture for transactions is to track each transaction for a payment rather than updating the its status, as the transactions can be created or deleted, but not updated.
Rather than porting XC’s architecture over to OrderCloud directly, there are some improvements we could introduce to reduce the complexity of the overall solution, which includes the business logic used in the order workflow and not just recreating the payment entities like for like. For example, if we treat transactions as a snapshot in time for a given payment, rather than a dynamic object representing only the most recent transaction, the
ResultCode would probably be better can be used for the raw transaction status given by the payment provider.
For the overall payment status, we can use the payment’s
xp to maintain the most recent transaction status in a normalised form, agnostic of payment provider, which would simply be translated as part of the payment provider integration.
Order minions are background jobs that process all orders in a given status to either perform some function on and/with the order, before transitioning it to its next status.
Pending Orders Minion
The pending orders minion is a shell for processing orders fresh from being placed. It is expected to be customised to fit each project’s requirements, and can be thought of as an extension of the create order process, delegated with performing asynchronous activities in a separate Commerce Engine runnning the minions role, which typically would run on dedicated resources. This is to mitigate any performance impacts on the Commerce Engine instance(s) running the shops role, which serves the storefront’s live traffic.
The pending order minion will usually be extended with processes such as exporting the order to an order management system (OMS), sending an order invoices via an email service provider, generating gift cards, activating subscriptions, and more.
In OrderCloud, we will review the order submit integration event and batch order processing approaches to process pending orders.
Order Submit Integration Event
The order submit integration event is a non-blocking asynchronous call to the middleware or dedicated jobs application, allowing you to process the order immediately. The downside to this approach is that unhandled exceptions and timeout issues may leave the order in a corrupt state, which may be difficult to diagnose.
Batch Order Processing
An alternate approach to integration events is to process orders in batch jobs, which is more closely aligned to pending orders minion behaviour, by leveraging the custom order status in the order
xp and the ElasticSearch backed premium search for orders. The benefit over using the batch approach is that, dependent on your system architecture, you may process orders in a separate custom application that is intended to process background jobs utilising separate resources from the middleware that services user traffic.
Released Orders Minion
The released orders minion processes orders in the released state by creating shipments against the order, generating entitlements, capture payments, then transition the order into a completed state as depicted in figure 12. We don’t need to bring over fault pipeline blocks, and as discussed in Orders – Shipments, we will be able to fold the shipment generation together.
To replicate the released orders minion in OrderCloud, we would need to follow the batch processing orders approach as described for the pending order minion equivalent behaviour.
While it might seem that the pending orders minion and released orders minion should be folded into a single process, the intention behind segregating these order states into separate processing jobs is due to the expected customisations, which may see manual triggering/transitioning or delayed processing between order states that will be considered against the project’s business requirements.
Waiting For Availability Orders Minion
The waiting for availability order minion simply iterates over orders in registered to the
WaitingForOrders list and determines if all products on the order have availability, in which they are returned to the
Pending status/list. It is intended to support back-order and preorder scenarios, however as these features aren’t completely functional, customisation is required to complete the implementation and cater for any unique business requirements.
Pre-order and backorder inventory features are not natively supported in OrderCloud and as XC’s implementation is also incomplete, we won’t cover how to port this across in detail, only to highlight that we can leverage the same batch processing approach we have already outlined as a framework for implementing this as an automated job.