upsertExpectedReceiptDateTime and upsertStore define delivery time and store. Finish with beginCheckout and finishOrder.

 

createOrder

mutation m1 {
createOrder(orders:[{
shoppingCartId: "<shoppingCartId>"
expectedReceiptDateTime: {
type: DELIVERY
from: "2037-12-24T00:00:00Z",
to: "2037-12-24T00:00:00Z"
timeFrame: "0-24"
}
constructionSite: {
code: "<code>"
} }]) {
orderId
shoppingCartId
status {
status
message
subStatus {
warning
}
}
}
}

Use the mutation createOrder  to create one ore more orders.  Add a shoppingCartId and a constructionSite to each order.

 

upsertExpectedReceiptDateTime

mutation m2 {
upsertExpectedReceiptDateTime(
orderIds: ["<orderId>"]
expectedReceiptDateTime: {
type: DELIVERY
from: "2037-12-24T00:00:00Z"
to: "2037-12-24T00:00:00Z"
timeFrame: "0-24"
}
) {
orderId
}
}

Use the  mutation upsertExpectedReceiptDateTime before starting the checkout process. Set the pickup or delivery time.

The default delivery time can is returned by connectedDistributionGates query. timeFrame 0-24 means "some time during the day".

 

upsertStore

mutation m3 {
upsertStore(orderIds: ["<orderId>"], store: {code: "<code>"}) {
orderId
}
}

Set the store; this is for billing purposes. The information is returned by the getUser query.  

 

beginCheckout

mutation m3 {
beginCheckout(orderIds: ["<orderId>"]) {
status {
status
}
}
}

Execute the mutation beginCheckout  to start the checkout process. Pass the orderIds with the mutatoin. The new status status.status of the order is then IN_CHECKOUT.

If you change the order by adding or removing products, the status is reset to NEW.

 

finishOrder

mutation m4 {
finishOrder(orderIds: ["<orderId>"]) {
status {
status
}
}
}

You can execute the mutation finishOrder if the status of the order is IN_CHECKOUT.

The new status is then FINISHING meaning that our system received the order and passed it to the ERP system of the distributor.

Execute the query "orders" until the status changed to FINISHED. Then, the "externalOrderNumber" is available as part of the response. This is the number of the order in the system of the distributor.