> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> 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`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - 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"}`.  | validation: format map
        - 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  | read-only: true 
        - name: price | type: number | description: Product price  | validation: minimum 0, maximum 999999999.99, format double
        - name: discountedPrice | type: number | description: Discounted product price (if no discounted price is set, the product price is returned)  | read-only: true 
        - name: formatted | type: FormattedPrice | description: The product price and discounted price, formatted with the currency  | read-only: true 
           - 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  | read-only: true 
        - name: pricePerUnit | type: number | description: Price per unit  | read-only: true | validation: format double
     - name: convertedPriceData | type: PriceData | description: Variant price data converted to currency provided in header.  | read-only: true 
     - name: weight | type: number | description: Variant weight.  | validation: format double
     - 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).  | validation: format int32
     - 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).  | validation: decimalValue {"gte":"0","lte":"999999999","maxScale":6}
        - name: width | type: string | description: Width. Measurement unit is handled at the system level (metric/imperial).  | validation: decimalValue {"gte":"0","lte":"999999999","maxScale":6}
        - name: height | type: string | description: Height. Measurement unit is handled at the system level (metric/imperial).  | validation: decimalValue {"gte":"0","lte":"999999999","maxScale":6}
        - 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.  | validation: format WEB_URL
              - name: width | type: integer | description: Media item width.  | validation: minimum 0
              - name: height | type: integer | description: Media item height.  | validation: minimum 0
              - 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<MediaItemUrlAndSize> | 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<MediaItem> | description: Media (images, videos etc) associated with this product.  
  - name: productOptions | type: array<ProductOption> | 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.  | read-only: true 
         - enum:
         -     unspecified_option_type: Unspecified option type.
         -     drop_down: Drop down.
         -     color: Color.
     - name: name | type: string | description: Option name.  | validation: minLength 1, maxLength 50
     - name: choices | type: array<Choice> | description: Choices available for this option.  | validation: minItems 1, maxItems 100
        - name: value | type: string | description: Choice value.  | validation: minLength 1, maxLength 50
        - name: description | type: string | description: Choice description.  | validation: minLength 1, maxLength 50
        - name: media | type: Media | description: Media items (images, videos) associated with this choice  | read-only: true 
        - name: inStock | type: boolean | description: Based on the customer’s choices, which (if any) variants that include the selected choices are in stock  | read-only: true 
        - name: visible | type: boolean | description: Based on the customer’s choices, which (if any) variants that include the selected choices are visible  | read-only: true 
  - 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: <AUTH>'
~~~
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.stores.products.getProductOptionsAvailability(_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 | validation: minLength 1
   param name: options | type: object | description: Array containing the selected options. For example, `{"color": "Blue", "size": "Large"}`. | required: true | validation: format map
        - name: key | type: string | description: none  
        - name: value | type: string | description: none  
 Return type: PROMISE<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  | read-only: true 
        - name: price | type: number | description: Product price  | validation: minimum 0, maximum 999999999.99
        - name: discountedPrice | type: number | description: Discounted product price (if no discounted price is set, the product price is returned)  | read-only: true 
        - name: formatted | type: FormattedPrice | description: The product price and discounted price, formatted with the currency  | read-only: true 
           - 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  | read-only: true 
        - name: pricePerUnit | type: number | description: Price per unit  | read-only: true 
     - name: convertedPriceData | type: PriceData | description: Variant price data converted to currency provided in header.  | read-only: true 
     - 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).  | validation: format int32
     - 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).  | validation: decimalValue {"gte":"0","lte":"999999999","maxScale":6}
        - name: width | type: string | description: Width. Measurement unit is handled at the system level (metric/imperial).  | validation: decimalValue {"gte":"0","lte":"999999999","maxScale":6}
        - name: height | type: string | description: Height. Measurement unit is handled at the system level (metric/imperial).  | validation: decimalValue {"gte":"0","lte":"999999999","maxScale":6}
        - 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.  | validation: format WEB_URL
              - name: width | type: integer | description: Media item width.  | validation: minimum 0
              - name: height | type: integer | description: Media item height.  | validation: minimum 0
              - 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<MediaItemUrlAndSize> | 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<MediaItem> | description: Media (images, videos etc) associated with this product.  
  - name: productOptions | type: array<ProductOption> | 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.  | read-only: true 
         - enum:
         -     unspecified_option_type: Unspecified option type.
         -     drop_down: Drop down.
         -     color: Color.
     - name: name | type: string | description: Option name.  | validation: minLength 1, maxLength 50
     - name: choices | type: array<Choice> | description: Choices available for this option.  | validation: minItems 1, maxItems 100
        - name: value | type: string | description: Choice value.  | validation: minLength 1, maxLength 50
        - name: description | type: string | description: Choice description.  | validation: minLength 1, maxLength 50
        - name: media | type: Media | description: Media items (images, videos) associated with this choice  | read-only: true 
        - name: inStock | type: boolean | description: Based on the customer’s choices, which (if any) variants that include the selected choices are in stock  | read-only: true 
        - name: visible | type: boolean | description: Based on the customer’s choices, which (if any) variants that include the selected choices are visible  | read-only: true 
  - 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-managed)
Self-managed 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);
};
```

---