When a Checkout Completion occurs, the Order Operation Service listens for it and goes through this workflow to generate a new order and fulfillment:
CheckoutCompletionListener
receives the checkout event, generates the Order
from the Cart
using
CartOrderGenerationService
and sends the event to the OrderCreatedProducer.CHANNEL
channel with the generated Order
.
The new order isn’t generated if one already exists for the cart
All relevant cart values are copied into the new order.
Customer name will be assigned from a billing address if it’s not available directly from the cart’s customer
If the CartItem
has the dependent cart items they will be translated into OrderItem.dependentOrderItems
,
mimicking the same item to dependent item hierarchical relationships.
OrderProvider
sends the new order to OrderServices
to persist
CartOrderFulfillmentGenerationService
generates new order fulfillment(s) for the cart fulfillments, if the new order was created successfully
Initially, one OrderFulfillment
is generated for each FulfillmentGroup
in the cart
All relevant fulfillment values are copied into the new order fulfillment
Each new order fulfillment might then be split into multiple based on the vendor for its items
After this, any given order fulfillment will only contain items from one vendor, with one fulfillment option, going to one destination
Each order fulfillment is assigned an identifying "Order Fulfillment Number"
For fulfillments with vendors, the number consists of the vendor reference, then a sequenced integer based on how many fulfillments share that vendor in this order (ex. "VENDOR-1" and "VENDOR-2")
For fulfillments without vendors, the fulfillment option name will be used instead of the vendor reference. For example, "SHIPPING-1" and "SHIPPING-2".
FulfillmentProvider
sends the new order fulfillments to OrderServices
to persist
An Order Created message is published, containing the generated order and its fulfillments