Skip to content

getProductVariantStockOptionValues(productId: number, selectedOptionsValuesSoFar: string[]): Promise

The getProductVariantStockOptionValues is an asynchronous method that allows to fetch a list of stock option values for a product variant by its id and selected options values so far.

Input parameters

productId - a number representing the product id.

selectedOptionsValuesSoFar - an array of strings representing the selected options values so far.

Returned value

A returned value has a type of Promise<string[]>.

Example

In this example we make a ProductFetcherApi call to get a list of stock option values for a product variant with id 1 and selected options values so far.

useStorefront(async (storefront) => {
    const productFetcherApi = await storefront.getApi('ProductFetcherApi');

    const stockOptionValues = await productFetcherApi.getProductVariantStockOptionValues(2, ['1', '2']);
    console.log(stockOptionValues);
});

Product Fetcher API methods reference