Search.../

queryProductVariants( )

Developer Preview

Retrieves product variants, based on either choices (option-choice key-value pairs) or variant IDs. See Stores Pagination for more information.

Syntax

function queryProductVariants(_id: string, options: QueryProductVariantsOptions): Promise<QueryProductVariantsResponse>

queryProductVariants Parameters

NAME
TYPE
DESCRIPTION
_id
string

Requested product ID.

options
Optional
QueryProductVariantsOptions

Returns

Return Type:

Promise<
QueryProductVariantsResponse
>
NAME
TYPE
DESCRIPTION
metadata
PagingMetadata
totalResults
number
variants
Array<
Variant
>

List of variants based on the specified filters and sorting.

Was this helpful?

queryProductVariants example

Copy Code
1import { products } from 'wix-stores.v2';
2
3 async function queryProductVariants(id, options) {
4 try {
5 const result = await products.queryProductVariants(id, options);
6
7 return result;
8 } catch (error) {
9 console.error(error);
10 // Handle the error
11 }
12 }
13