$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
"ƒ()" 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 valuemap - 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 valuemap - Reservation data with the following attributes:
Parameters
Example that loads reservation data.
Actions
No actions are available for$wsInventory.
