> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: getProductOptionsAvailability(productId: string, choices: ProductChoices) # Method package: wixStoresBackend # Method menu location: wixStoresBackend --> getProductOptionsAvailability # Method Link: https://dev.wix.com/docs/velo/apis/wix-stores-backend/get-product-options-availability.md # Method Description: Gets the availability of a product based on the specified option choices. The `getProductOptionsAvailability()` function returns a Promise that is resolved to a `ProductOptionsAvailability` object when the product's availability information is retrieved. The information returned in the `selectedVariant` and `availableForPurchase` properties reflects the option choices passed in using the `ProductChoices` parameter. If the specified choices result in the selection of a single product variant, that variant is returned in the `selectedVariant` property and the `availableForPurchase` property indicates whether that product variant is available for purchase. If the specified choices do not result in the selection of a single product variant, no variant is returned in the `selectedVariant` property and the `availableForPurchase` property will be `false`. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Get a product's availability information ```javascript /******************************* * Backend code - products.jsw * *******************************/ import wixStoresBackend from 'wix-stores-backend'; export function getProductOptionsAvailability(productId, choices) { return wixStoresBackend.getProductOptionsAvailability(productId, choices); } /************* * Page code * *************/ import { getProductOptionsAvailability } from 'backend/products'; // ... let productId = // get product ID; let choices = { "Size": "Large" }; getProductOptionsAvailability(productId, choices) .then((availability) => { let available = availability.availableForPurchase; // false let options = availability.productOptions; // see below let mainMedia = availability.mainMedia; let mediaItems = availability.mediaItems; let selectedVariant = availability.selectedVariant; // null }) .catch((error) => { console.log(error); }); /* * options: * * "Size": { * "optionType": "drop_down", * "name": "Size", * "choices": [ * { * "value": "Small", * "description": "Small", * "inStock": true, * "visible": true * }, * { * "value": "Large", * "description": "Large", * "inStock": true, * "visible": true * } * ] * }, * "Color": { * "optionType": "color", * "name": "Color", * "choices": [ * { * "value": "rgb(0, 128, 0)", * "description": "green", * "inStock": true, * "visible": true * }, * { * "value": "rgb(255, 0, 0)", * "description": "red", * "inStock": true, * "visible": true * } * ] * } */ ``` ## Get a product's availability information ```javascript /******************************* * Backend code - products.jsw * *******************************/ import wixStoresBackend from 'wix-stores-backend'; export function getProductOptionsAvailability(productId, choices) { return wixStoresBackend.getProductOptionsAvailability(productId, choices); } /************* * Page code * *************/ import { getProductOptionsAvailability } from 'backend/products'; // ... let productId = // get product ID let choices = { "Size": "Large", "Color": "Red" }; getProductOptionsAvailability(productId, choices) .then((availability) => { let available = availability.availableForPurchase; // true let options = availability.productOptions; // see below let mainMedia = availability.mainMedia; let mediaItems = availability.mediaItems; let selectedVariant = availability.selectedVariant; // see below }) .catch((error) => { console.log(error); }); /* * options: * * "Size": { * "optionType": "drop_down", * "name": "Size", * "choices": [ * { * "value": "Small", * "description": "Small", * "inStock": true, * "visible": true * }, * { * "value": "Large", * "description": "Large", * "inStock": true, * "visible": true * } * ] * }, * "Color":{ * "optionType": "color", * "name": "Color", * "choices": [ * { * "value": "rgb(0, 128, 0)", * "description": "green", * "inStock": true, * "visible": true * }, * { * "value": "rgb(255, 0, 0)", * "description": "red", * "inStock": true, * "visible": true * } * ] * } * * * selectedVariant: * * "selectedVariant":{ * "sku": "366615376135191", * "currency": "USD", * "price": 7.5, * "discountedPrice": 7.5, * "formattedPrice": "$7.50", * "formattedDiscountedPrice": "$7.50", * "visible": true, * "inStock": true, * "weight": 0 * } */ ``` ---