Skip to main content
With the $wsInventory module, you can access stock levels and product availability. Typical use cases are traffic-light displays (green/yellow/red), availability checks on product pages, or reservation times in the basket. In this section, you will learn how to load and display stock data.

Module overview

Example / excerpt of $wsInventory
JSON output
Note: "ƒ()" denotes a function. Methods overview

Templates

Typically, information on stock levels and availability is loaded together with the products – for example on the home page, the category list, the search results, or in the basket.

Variables

No direct variables are available for $wsInventory. The data is loaded via methods.

Methods

$wsInventory.load()

Loads the stock data of a product. Signature
$wsInventory.load(productId)
Return value
map - Map with stock data.
Parameters Example that loads and outputs stock data.
By using the $wsInventory.load() function, various variables are available to retrieve and output stock data. Below is an overview of which variables are available.Stock data (return value of $wsInventory.load() )First, it is necessary to assign the map with the stock data, as shown in the example above, to a local variable. This can then be used at various places in the template.Stock data overview

$wsInventory.loadReservation()

Loads the reservation data of a basket item. Signature
$wsInventory.loadReservation(basketItemId)
Return value
map - Reservation data with the following attributes:
Parameters Example that loads reservation data.

Actions

No actions are available for $wsInventory.

Examples for displaying stock

Check for stock management

This example checks whether stock management is active for this product.

Stock data

This example displays the product-specific data.

Display traffic light status

This example checks the product’s availability so that the customer can immediately see whether it is available, almost sold out, or not deliverable.

Display for reservation time

After a product has been added to the basket, the product can be reserved for a certain time. In this example, the reservation time is displayed in the basket.

Extend reservation time

To give the customer a bit more time to decide, the reservation time can be extended in the basket.
You can find more practical examples here: Stock