Skip to content

Stock

Overview of the main stock classes

Syntax error in textmermaid version 11.4.1

ProductStock has a field InStock that holds the last stock value received from whatever integration provices the stock values. The other field, Reserved, is how many we sold in the webshop since the last time we received the stock value.

So in order to get the available stock you have to do the following calculation: InStock - Reserved.

When we syncronize stock values we set the Reserved back to 0.

This design with a reserved stock value protects the webshop from overselling products without throwing away information about the last received stock value.

Backend and frontend functionality

Stock status is displayed in a number of pages incl. PLP, PDP, Basket, Checkout. All the backend APIs supporting these pages return stock levels.

In the frontend we display a "traffic light" for these three stock levels:

  1. In stock - green.
  2. Few in stock - yellow.
  3. Out of stock - red.

Less than 10 in stock triggers the "few in stock". The specific number of products for each level is currently hardcoded. But this can easily be moved to a config or the product category or product in the PIM.