The JS Buy SDK is deprecated as of January, 2025. For more information, please see the README.

Namespace: ProductHelpers

ProductHelpers

Methods

(static) variantForOptions(product, options) → {GraphModel}

Returns the variant of a product corresponding to the options given.

Parameters:
Name Type Description
product GraphModel

The product to find the variant on. Must include variants.

options Object

An object containing the options for the variant.

Source:
Returns:

The variant corresponding to the options given.

Type
GraphModel
Example
const selectedVariant = client.product.helpers.variantForOptions(product, {
  size: "Small",
  color: "Red"
});