Order
Overview of the main order classes
classDiagram
direction TB
class Order {
Id
UniqueId
Status
CreatedTime
Email
PhoneNumber
Comment
}
class OrderLine {
ProductVariantId
Quantity
Price
ListPrice
VatPercentage
Status
}
class Account {
Id
Name
}
class Basket {
Id
}
class Address {
Name
AddressOne
AddressTwo
City
ZipCode
Country
}
Basket "1" <-- "0..n" Order
Order --o "1..n" OrderLine
Order --> "1..2" Address
Order "0..n" --> "0..1" Account
The Order
is based on a specific basket.
Just like the basket it has a number of lines.
Each line has information about one product in the order.
The Order
has a billing address, but also an optional different
delivery address.
The order is associated with an account if the user was logged in when the order was placed.
Order ids
The Order
has two ids. The Id
is a simple human readable numerical value.
The UniqueId
is a cryptographically random hexadecimal string.
Id
Use the Id
for communication with the customer and as the webshop's
order id in a backend ERP-integration or similar.
UniqueId
The UniqueId
is used for public links to the order confirmation.
The order confirmation does not require the user to be logged in to the site.
So we need a secure id here to prevent users from guessing the URL to other
order confirmations.
Order status
The Order
has a status. Currently the following values are possible:
- AwaitingPayment
- Failed
- Paid
- Cancelled
- Refunded
- Captured
The OrderLine
also has a separate status with the following possible values:
- Created
- OutOfStock
- StockReserved
- Cancelled
These values are just a starting point. You can easily modify them to the specific needs in the webshop you are building.
Example
Assuming a payment provider is used the the webshop, the Order
starts with status "AwaitingPayment".
Then after the user has successfully gone through the payment flow, the Order
is moved to status "Paid". This then usually triggers the Order
to be
exported to an ERP-system for further processing.
An ERP-integration of order status then updates the status to "Captured" once the products have been sent.
Backend API
The backend API for orders has been kept very simple.
You can create an Order
based on your current basket.
You can get an Order
by UniqueId
.
If the order is more than 10 minutes old and the user is not logged in,
you also have to provide the phone number from the order. This is extra
security added to the endpoint, so that you can't replay something from
the browser history to see the order details from someone elses order.
If the order is closed or more than 30 days old, you can no longer get the
details from this public endpoint.
Frontend functionality
The Order
is created from checkout page and the order details are displayed
on the order confirmation page.