Product page
How to display price and availability on a product page
The Problem
You've created a product page with your favorite CMS and now you want to display the price and the availability of the selected product. You also need to implement the "add to cart" function on the related button.
Solution
To retrieve the price and availability of an SKU, send a GET
request to the /api/skus/:id
endpoint and include the associated prices.
Example
The following request retrieves the price and the availability of the SKU identified by the "aBmNkPQRst" ID:
For performance reasons, the inventory
information is only returned when fetching a single SKU.
To implement the "add to cart" function, please refer to this guide:
Adding products to cartMapping
The image below shows the three main dynamic elements of the page (selling price, full price and inventory information) and how each of these are mapped to a specific field of the SKU or price objects.
Additional notes
Getting the SKU ID from its code
If you have the SKU code and you want to retrieve the related ID, send a GET
request to the /api/skus
endpoint and filter it by code, taking care to request the ID field only.
The following request retrieves the ID of the SKU identified by the code "TSHIRTB5B5B5XL":
Getting a list of SKU prices
If you need to display the prices associated with a list of SKUs (with no inventory information) send a GET
request to the /api/skus
endpoint, filter it by code, and include the SKU prices.
The following request retrieves the prices of the SKU identified by the "TSHIRTB5B5B5XL" code:
More to read
See our documentation if you need more information on how to filter data, include associations, and manage sparse fieldsets or if you want to have an overview of all the specific permissions and restrictions set for a sales channel API client.
Last updated