Skip to main content

Class: Variant

A wrapping component that provides a simple interface for interacting with a variant.

Constructors​

Constructor​

new Variant(variant): Variant

Parameters​

variant​

VariantResource

Returns​

Variant

Methods​

getAsset()​

getAsset(): string | undefined

Returns​

string | undefined

The URL for the base asset resource configured on this variant


getAssetResource()​

getAssetResource(): Asset | undefined

Returns​

Asset | undefined

The URL for the base asset resource configured on this variant


getCategory()​

getCategory(): string | undefined

Returns​

string | undefined

The category for grouping variants in an option.


getColor()​

getColor(): string | undefined

Returns​

string | undefined

When this variant is configured to have a color, this will return the hex value for that color.


getId()​

getId(): string

Returns​

string

The unique identifier for the variant.


getName()​

getName(): string

Returns​

string

The configured name of the variant. Generally a human readable value.


getPrice()​

getPrice(): number

Returns​

number

The price modifier for this variant. This is the amount that will be added to the base price of the product. Presented in subunits of the currency of the option. For example, if the option is configured to use USD, the price modifier will be in cents.


getPriceFormatted()​

getPriceFormatted(locales?, options?): string

Parameters​

locales?​

LocalesArgument

options?​

NumberFormatOptions

Returns​

string

The price modifier for this variant. This is the amount that will be added to the base price of the product.


getProduct()​

getProduct(): Product | undefined

Returns​

Product | undefined

The product associated with this variant.


getResource()​

getResource(): VariantResource

Returns​

VariantResource

The underlying variant resource. Generally not needed but made available just in case.


getThumbnail()​

getThumbnail(resolution?, quality?): string | undefined

Parameters​

resolution?​

number = 256

quality?​

number

Returns​

string | undefined

The URL for a thumbnail resource configured on this variant.


getType()​

getType(): AssetType | undefined

Returns​

AssetType | undefined


isDefault()​

isDefault(): boolean

Returns​

boolean

True when the variant is the default for its containing option. False otherwise.


isEnabled()​

isEnabled(): boolean

Returns​

boolean

True when the variant is enabled. False otherwise.