> 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

# Method name: getProductVariants(productId: string, options: ProductVariantOptions)

# Method package: wixStoresBackend

# Method menu location: wixStoresBackend --> getProductVariants

# Method Link: https://dev.wix.com/docs/velo/apis/wix-stores-backend/get-product-variants.md

# Method Description:

Gets a product's available variants based on the specified product ID and either option choices or variant IDs.

The `getProductVariants()` function returns a Promise that is resolved
 to an array of `VariantItem` objects when the product variants with the specified
 choices or variant IDs are retrieved.



# Method Code Examples:

*** Note: do not assume any prop names or enum values other than the ones in the example.

## Get product variants by specified choices

```javascript
/*******************************
 * Backend code - products.jsw *
 *******************************/

import wixStoresBackend from 'wix-stores-backend';

export function getProductVariants(productId, options) {
  return wixStoresBackend.getProductVariants(productId, options);
}

/*************
 * Page code *
 *************/

import { getProductVariants } from 'backend/products';

let productId = "3fb6a3c8-988b-7895-04bd-5c59ae0b18ea"; // get product ID
let options = {
  choices: {
    "Size": "Large",
    "Color": "Red"
  }
};

getProductVariants(productId, options)
  .then((variants) => {
    let firstVariant = variants[0];
    let firstPrice = firstVariant.variant.price;
    let numberOfReturnedVariants = variants.length;
  })
  .catch((error) => {
    console.error(error);
  })

/* Example of returned variants array:
 *
 * [
 *   {
 *     "_id": "00000000-0000-03e1-0005-957f699d0688",
 *     "choices": {
 *       "Size": "Large",
 *       "Color": "Red",
 *       "Pattern": "Paisley"
 *     },
 *     "variant": {
 *       "currency": "USD",
 *       "price": 25,
 *       "discountedPrice": 25,
 *       "formattedPrice": "$25.00",
 *       "formattedDiscountedPrice": "$25.00",
 *       "pricePerUnit": 0.25,
 *       "formattedPricePerUnit": "$0.25",
 *       "weight": 5,
 *       "sku": "217537123517253",
 *       "visible": true
 *     }
 *   },
 *   {
 *     "id": "00000000-0000-03e2-0005-957f699d0688",
 *     "choices": {
 *       "Size": "Large",
 *       "Color": "Red",
 *       "Pattern": "Houndstooth"
 *     },
 *     "variant": {
 *       "currency": "USD",
 *       "price": 25,
 *       "discountedPrice": 25,
 *       "formattedPrice": "$25.00",
 *       "formattedDiscountedPrice": "$25.00",
 *       "pricePerUnit": 0.25,
 *       "formattedPricePerUnit": "$0.25",
 *       "weight": 5,
 *       "sku": "217537123517253",
 *       "visible": true
 *     }
 *   }
 * ]
 *
 */
```

## Get product variants by variant IDs

```javascript
/*******************************
 * Backend code - products.jsw *
 *******************************/

import wixStoresBackend from 'wix-stores-backend';

export function getProductVariants(productId, options) {
  return wixStoresBackend.getProductVariants(productId, options);
}

/********************
 * Client-side code *
 ********************/
import { getProductVariants } from 'backend/products';

let productId = "3fb6a3c8-988b-7895-04bd-5c59ae0b18ea"; // get product ID
let options = {
  variantIds: [
    "00000000-0000-03e1-0005-957f699d0688",
    "00000000-0000-03e2-0005-957f699d0688"
  ]
};

getProductVariants(productId, options)
  .then((variants) => {
    let firstVariant = variants[0];
    let firstPrice = firstVariant.variant.price;
    let numberOfReturnedVariants = variants.length;
  })
  .catch((error) => {
    console.error(error);
  })

/* Example of returned variants array:
 *
 * [
 *   {
 *     "_id": "00000000-0000-03e1-0005-957f699d0688",
 *     "choices": {
 *       "Size": "Large",
 *       "Color": "Red",
 *       "Pattern": "Paisley"
 *     },
 *     "variant": {
 *       "currency": "USD",
 *       "price": 25,
 *       "discountedPrice": 25,
 *       "formattedPrice": "$25.00",
 *       "formattedDiscountedPrice": "$25.00",
 *       "pricePerUnit": 0.25,
 *       "formattedPricePerUnit": "$0.25",
 *       "weight": 5,
 *       "sku": "217537123517253",
 *       "visible": true
 *     }
 *   },
 *   {
 *     "id": "00000000-0000-03e2-0005-957f699d0688",
 *     "choices": {
 *       "Size": "Large",
 *       "Color": "Red",
 *       "Pattern": "Houndstooth"
 *     },
 *     "variant": {
 *       "currency": "USD",
 *       "price": 25,
 *       "discountedPrice": 25,
 *       "formattedPrice": "$25.00",
 *       "formattedDiscountedPrice": "$25.00",
 *       "pricePerUnit": 0.25,
 *       "formattedPricePerUnit": "$0.25",
 *       "weight": 5,
 *       "sku": "217537123517253",
 *       "visible": true
 *     }
 *   }
 * ]
 *
 */
```

---