Basket
Overview of the main basket classes
classDiagram
direction TB
class WebsiteUser {
Id
Name
Email
UserName
PhoneNumber
LoginStatus
EmailConfirmed
}
class Basket {
Id
}
class BasketLine {
ProductVariantId
Quantity
}
class CalculatedBasket {
}
class CalculatedBasketLine {
ProductVariantId
Quantity
Price
ListPrice
ProductName
Image
Url
Brand
}
Basket --> "0..1" WebsiteUser
Basket --o "0..n" BasketLine
CalculatedBasket --> "1" Basket
CalculatedBasket --> "0..1" WebsiteUser
CalculatedBasket --o "0..n" CalculatedBasketLine
The Basket
only contains information about how many of each product are in the basket.
This is the data we persist in the database (note, we only persist non-empty baskets).
Before the basket can be displayed to the user it gets calculated. The result is the CalculatedBasket
.
The CalculatedBasket
has been enriched with prices, discounts and product information. This result gets cached and it is what we show to the user.
Every time the contents of the basket is changed we re-calculate the basket.
User association
If the user is not logged in to the website the basket id is stored in a cookie. So if the user revisits the webshop in the same browser, the basket is continued as long as the cookie has not been removed.
If the user decides to log in to the website then the basket gets associated with the WebsitUser-entity. In this scenario the user can revisit the webshop from another browser or device and continue with the same basket as long as their are logged into the website.
When you buy the basket (create an order) the basket is always soft deleted and the user gets a new basket.
Backend API
The backend API of the website provides the following functionality:
- Get the current basket.
- Get the total quantity of the basket (can be used to display the little counter on a minibasket without fetching the whole basket).
- Add a new basket line.
- Set the quantity on a basket line.
- Remove a basket line.
Frontend functionality
In the website we have the following functionality:
- A minibasket in the header.
- A quick basket you can use when you mouse over the minibasket.
- A dedicated static page for displaying and working with the basket.
- Basket overviews for the checkout- and order confirmation-pages.