> 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 # ProductOptionsAvailability # Package: catalogV1 # Namespace: CatalogReadApi # Method link: https://dev.wix.com/docs/api-reference/business-solutions/stores/catalog-v1/catalog/get-product-options-availability.md ## Permission Scopes: Read Products: SCOPE.DC-STORES.READ-PRODUCTS ## Introduction Gets the availability of relevant product variants based on the product ID and selections provided. See [Use Cases](https://dev.wix.com/api/rest/wix-stores/catalog/use-cases) for an example. --- ## REST API ### Schema ``` Method: productOptionsAvailability Description: Gets the availability of relevant product variants based on the product GUID and selections provided. See [Use Cases](https://dev.wix.com/api/rest/wix-stores/catalog/use-cases) for an example. URL: https://www.wixapis.com/stores-reader/v1/products/{id}/productOptionsAvailability Method: POST Method parameters: param name: options | type: options | description: Array containing the selected options. For example, `{"color": "Blue", "size": "Large"}`. - name: key | type: string | description: none - name: value | type: string | description: none Return type: ProductOptionsAvailabilityResponse - name: selectedVariant | type: VariantData | description: Variant information, given that all the choices were provided. - name: price | type: PriceData | description: Variant price. - name: currency | type: string | description: Product price currency - name: price | type: number | description: Product price - name: discountedPrice | type: number | description: Discounted product price (if no discounted price is set, the product price is returned) - name: formatted | type: FormattedPrice | description: The product price and discounted price, formatted with the currency - name: price | type: string | description: Product price formatted with the currency - name: discountedPrice | type: string | description: Discounted product price formatted with the currency (if no discounted price is set, the product formatted price is returned) - name: pricePerUnit | type: string | description: Price per unit - name: pricePerUnit | type: number | description: Price per unit - name: convertedPriceData | type: PriceData | description: Variant price data converted to currency provided in header. - name: weight | type: number | description: Variant weight. - name: sku | type: string | description: Variant SKU (stock keeping unit). - name: quantity | type: integer | description: Quantity currently in inventory (relevant only when tracking by inventory). - name: inStock | type: boolean | description: Whether the product is currently in stock (relevant only when tracking manually). - name: visible | type: boolean | description: Whether the variant is visible to customers. - name: productDimensions | type: Dimensions | description: Product dimensions (length, width, height of the physical product). - name: length | type: string | description: Length. Measurement unit is handled at the system level (metric/imperial). - name: width | type: string | description: Width. Measurement unit is handled at the system level (metric/imperial). - name: height | type: string | description: Height. Measurement unit is handled at the system level (metric/imperial). - name: unit | type: DimensionsUnit | description: Unit of measurement for dimensions (length, width, height). - enum: - UNKNOWN_DIMENSIONS_UNIT: - MM: Millimeters. - CM: Centimeters. - M: Meters. - IN: Inches. - FT: Feet. - YD: Yards. - name: packageDimensions | type: Dimensions | description: Package dimensions (length, width, height of the shipping package). - name: media | type: Media | description: Information about media items (images, videos, etc.) associated with this choice. - name: mainMedia | type: MediaItem | description: Primary media (image, video etc) associated with this product. - ONE-OF: - name: image | type: MediaItemUrlAndSize | description: Image data (URL, size). - name: url | type: string | description: Media item URL. - name: width | type: integer | description: Media item width. - name: height | type: integer | description: Media item height. - name: format | type: string | description: Media format (mp4, png, etc.). - name: altText | type: string | description: Alt text. This text will be shown in case the image is not available. - name: video | type: MediaItemVideo | description: Video data (URL, size). - name: files | type: array | description: Data (URL, size) about each resolution for which this video is available. - name: stillFrameMediaId | type: string | description: GUID of an image taken from the video. Used primarily for Wix Search indexing. For example, `"nsplsh_306d666a123a4a74306459~mv2_d_4517_2992_s_4_2.jpg"`. - name: thumbnail | type: MediaItemUrlAndSize | description: Media item thumbnail details. - name: mediaType | type: MediaItemType | description: Media item type (image, video, etc.). - enum: - unspecified_media_item_type: - image: Image media type. - video: Video media type. - audio: Audio media type. - document: Document media type. - zip: Zip media type. - name: title | type: string | description: Media item title. - name: id | type: string | description: Media GUID (for example, `"nsplsh_306d666a123a4a74306459~mv2_d_4517_2992_s_4_2.jpg"`). - name: items | type: array | description: Media (images, videos etc) associated with this product. - name: productOptions | type: array | description: Options information (color, size, etc.) for this product, with the inventory and visibility fields updated based on the provided choices. - name: optionType | type: OptionType | description: Option type. - enum: - unspecified_option_type: Unspecified option type. - drop_down: Drop down. - color: Color. - name: name | type: string | description: Option name. - name: choices | type: array | description: Choices available for this option. - name: value | type: string | description: Choice value. - name: description | type: string | description: Choice description. - name: media | type: Media | description: Media items (images, videos) associated with this choice - name: inStock | type: boolean | description: Based on the customer’s choices, which (if any) variants that include the selected choices are in stock - name: visible | type: boolean | description: Based on the customer’s choices, which (if any) variants that include the selected choices are visible - name: availableForPurchase | type: boolean | description: Whether all the selected choices result in a visible, in-stock variant. ``` ### Examples ### ProductOptionsAvailability ```curl ~~~cURL curl -X POST \ 'https://www.wixapis.com/stores/v1/products/1044e7e4-37d1-0705-c5b3-623baae212fd/productOptionsAvailability' \ --data-binary '{ "options": { "Size": "S", "Color": "Green" } }' \ -H 'Content-Type: application/json' \ -H 'Authorization: ' ~~~ ``` --- ## JavaScript SDK ### Schema ``` Method: wixClientAdmin.catalogV1.CatalogReadApi.productOptionsAvailability(_id, options) Description: Gets the availability of relevant product variants based on the product GUID and selections provided. See [Use Cases](https://dev.wix.com/api/rest/wix-stores/catalog/use-cases) for an example. # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present. Required parameters: _id, options Method parameters: param name: _id | type: string | description: Requested product GUID. | required: true param name: options | type: object | description: Array containing the selected options. For example, `{"color": "Blue", "size": "Large"}`. | required: true - name: key | type: string | description: none - name: value | type: string | description: none Return type: PROMISE - name: selectedVariant | type: VariantData | description: Variant information, given that all the choices were provided. - name: price | type: PriceData | description: Variant price. - name: currency | type: string | description: Product price currency - name: price | type: number | description: Product price - name: discountedPrice | type: number | description: Discounted product price (if no discounted price is set, the product price is returned) - name: formatted | type: FormattedPrice | description: The product price and discounted price, formatted with the currency - name: price | type: string | description: Product price formatted with the currency - name: discountedPrice | type: string | description: Discounted product price formatted with the currency (if no discounted price is set, the product formatted price is returned) - name: pricePerUnit | type: string | description: Price per unit - name: pricePerUnit | type: number | description: Price per unit - name: convertedPriceData | type: PriceData | description: Variant price data converted to currency provided in header. - name: weight | type: number | description: Variant weight. - name: sku | type: string | description: Variant SKU (stock keeping unit). - name: quantity | type: integer | description: Quantity currently in inventory (relevant only when tracking by inventory). - name: inStock | type: boolean | description: Whether the product is currently in stock (relevant only when tracking manually). - name: visible | type: boolean | description: Whether the variant is visible to customers. - name: productDimensions | type: Dimensions | description: Product dimensions (length, width, height of the physical product). - name: length | type: string | description: Length. Measurement unit is handled at the system level (metric/imperial). - name: width | type: string | description: Width. Measurement unit is handled at the system level (metric/imperial). - name: height | type: string | description: Height. Measurement unit is handled at the system level (metric/imperial). - name: unit | type: DimensionsUnit | description: Unit of measurement for dimensions (length, width, height). - enum: - UNKNOWN_DIMENSIONS_UNIT: - MM: Millimeters. - CM: Centimeters. - M: Meters. - IN: Inches. - FT: Feet. - YD: Yards. - name: packageDimensions | type: Dimensions | description: Package dimensions (length, width, height of the shipping package). - name: media | type: Media | description: Information about media items (images, videos, etc.) associated with this choice. - name: mainMedia | type: MediaItem | description: Primary media (image, video etc) associated with this product. - ONE-OF: - name: image | type: MediaItemUrlAndSize | description: Image data (URL, size). - name: url | type: string | description: Media item URL. - name: width | type: integer | description: Media item width. - name: height | type: integer | description: Media item height. - name: format | type: string | description: Media format (mp4, png, etc.). - name: altText | type: string | description: Alt text. This text will be shown in case the image is not available. - name: video | type: MediaItemVideo | description: Video data (URL, size). - name: files | type: array | description: Data (URL, size) about each resolution for which this video is available. - name: stillFrameMediaId | type: string | description: GUID of an image taken from the video. Used primarily for Wix Search indexing. For example, `"nsplsh_306d666a123a4a74306459~mv2_d_4517_2992_s_4_2.jpg"`. - name: thumbnail | type: MediaItemUrlAndSize | description: Media item thumbnail details. - name: mediaType | type: MediaItemType | description: Media item type (image, video, etc.). - enum: - unspecified_media_item_type: - image: Image media type. - video: Video media type. - audio: Audio media type. - document: Document media type. - zip: Zip media type. - name: title | type: string | description: Media item title. - name: _id | type: string | description: Media GUID (for example, `"nsplsh_306d666a123a4a74306459~mv2_d_4517_2992_s_4_2.jpg"`). - name: items | type: array | description: Media (images, videos etc) associated with this product. - name: productOptions | type: array | description: Options information (color, size, etc.) for this product, with the inventory and visibility fields updated based on the provided choices. - name: optionType | type: OptionType | description: Option type. - enum: - unspecified_option_type: Unspecified option type. - drop_down: Drop down. - color: Color. - name: name | type: string | description: Option name. - name: choices | type: array | description: Choices available for this option. - name: value | type: string | description: Choice value. - name: description | type: string | description: Choice description. - name: media | type: Media | description: Media items (images, videos) associated with this choice - name: inStock | type: boolean | description: Based on the customer’s choices, which (if any) variants that include the selected choices are in stock - name: visible | type: boolean | description: Based on the customer’s choices, which (if any) variants that include the selected choices are visible - name: availableForPurchase | type: boolean | description: Whether all the selected choices result in a visible, in-stock variant. ``` ### Examples ### Get a product's availability information This example gets a product's availability information using an option choice. The product contains more than one option, so no variant is selected and the product with the specified choices is not available for purchase. ```javascript /************************************** * Backend code - products.web.js/ts * **************************************/ import { Permissions, webMethod } from '@wix/web-methods'; import { products } from '@wix/stores'; export const getProductOptionsAvailability = webMethod(Permissions.Anyone, (_id, options) => { return products.getProductOptionsAvailability(_id, options); }); /************* * Page code * *************/ import { getProductOptionsAvailability } from 'backend/products.web'; // ... let _id = // get product ID; let options = { "Size": "Large" }; getProductOptionsAvailability(_id, options) .then((availability) => { let availableForPurchase = availability.availableForPurchase; // false let productOptions = availability.productOptions; // see below let mainMedia = availability.media.mainMedia; let media = availability.media; let selectedVariant = availability.selectedVariant; // null }) .catch((error) => { console.log(error); }); /* * productOptions: * * "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 * } * ] * } */ ``` ### getProductOptionsAvailability (self-hosted) Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md). ```javascript import { createClient } from '@wix/sdk'; import { products } from '@wix/stores'; // Import the auth strategy for the relevant access type // Import the relevant host module if needed const myWixClient = createClient ({ modules: { products }, // Include the auth strategy and host as relevant }); async function getProductOptionsAvailability(_id,options) { const response = await myWixClient.products.getProductOptionsAvailability(_id,options); }; ``` ---