> 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: 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 * } * } * ] * */ ``` ---