Delivery state machine
The delivery state machine defines the states and transitions of a delivery.
A single order may have multiple deliveries, and therefore may have multiple delivery states (one status for each delivery).
The implementation project may decide to customise the delivery state machine by adding or removing states, or modifying the various conditions and transitions among them.
The default delivery state machine has four states:
- Init: Initial state.
- Delivered: Delivery is successful.
- Failed: Delivery failed.
- Cancelled: Delivery is cancelled.

When a delivery goes to the Delivered state, the order will be automatically set to the Processing state. If all deliveries are Delivered and all payments are Paid, the order is automatically set to the state Completed. If at least one delivery fails, the order is set to the Attention state.