Search...
getProductOptionsAvailability( )
Gets the availability of relevant product variants based on the product ID and selections provided. See Use Cases for an example.
Syntax
function getProductOptionsAvailability(_id: string, options: Record<string, string>): Promise<ProductOptionsAvailabilityResponse>
getProductOptionsAvailability Parameters
NAME
TYPE
DESCRIPTION
_id
string
Requested product ID.
options
Record<
string
>,
stringArray containing the selected options. For example, ["color": "Blue", "size": "Large"]
.
Returns
Return Type:
Promise<
ProductOptionsAvailabilityResponse
>NAME
TYPE
DESCRIPTION
availableForPurchase
boolean
Whether all the selected choices result in a visible, in-stock variant.
media
Media
Information about media items (images, videos, etc.) associated with this choice.
productOptions
Array<
ProductOption
>Options information (color, size, etc.) for this product, with the inventory and visibility fields updated based on the provided choices.
selectedVariant
VariantData
Variant information, given that all the choices were provided.
Was this helpful?
getProductOptionsAvailability example
Copy Code
1import { products } from 'wix-stores.v2';23 async function getProductOptionsAvailability(id, options) {4 try {5 const result = await products.getProductOptionsAvailability(id, options);67 return result;8 } catch (error) {9 console.error(error);10 // Handle the error11 }12 }13