Every Order has a
state property of type
OrderState. The following diagram shows the default states and how an Order transitions from one to the next.
Structure of an Order
In Vendure an Order consists of one or more OrderLines (representing a given quantity of a particular SKU), which in turn contain one or more OrderItems (which represent the individual physical units).
Here is a simplified diagram illustrating this relationship:
So if the customer adds 2 Widgets to the Order, there will be one OrderLine containing two OrderItems, one for each of the added Widgets.
Shop client order workflow
The following is a description of the flow and related GraphQL operations which are used when dealing with Orders in a customer-facing client application (i.e. a storefront).
activeOrderquery returns the currently-active Order for the session.
addItemToOrdermutation adds an item to the order. The first time it is called will also create a new Order for the session.
adjustOrderLinemutation is used to adjust the quantity of an OrderLine.
removeOrderLinemutation removes an OrderLine from the Order.
setCustomerForOrdermutation specifies the Customer details (required if the customer is not logged in as an authenticated user).
setOrderShippingAddressmutation sets the shipping address for the Order.
eligibleShippingMethodsquery returns all available shipping methods based on the customer’s shipping address and the contents of the Order.
setOrderShippingMethodmutation sets the shipping method to use.
addPaymentToOrdermutation adds a payment to the Order. If the payment amount equals the order total, then the Order will be transitioned to either the
PaymentSettledstate (depending on how the payment provider is configured) and the order process is complete from the customer’s side.