Skip to main content

variant

Properties

Returns true if the variant is available. Returns false if not.

The barcode of the variant.

Anchor to
compare_at_price

The compare at price of the variant in the currency's subunit.

The value is output in the customer's local (presentment) currency.

For currencies without subunits, such as JPY and KRW, tenths and hundredths of a unit are appended. For example, 1000 Japanese yen is output as 100000.

Tip

Use money filters to output a formatted price.

The image attached to the variant.

Note

This is the same value as variant.image.

The first media object attached to the variant.

The ID of the variant.

The image attached to the variant.

Note

This is the same value as variant.featured_image.

Returns true if the variant has incoming inventory. Returns false if not.

Incoming inventory information is populated by inventory transfers, purchase orders, and third-party apps.

Anchor to
inventory_management

The inventory management service of the variant.

If inventory isn't tracked, then nil is returned.

Anchor to
inventory_policy
string from a set of values

Whether the variant should continue to be sold when it's out of stock.

Tip

To learn about why merchants might want to continue selling products when they're out of stock, visit the Shopify Help Center.

Possible valuesDescription
continueContinue selling when the variant is out of stock.
denyStop selling when the variant is out of stock.
Anchor to
inventory_quantity

The inventory quantity of the variant.

If inventory isn't tracked, then the number of items sold is returned.

Returns true if the variant has been matched by a storefront filter or no filters are applied. Returns false if it hasn't.

Anchor to
metafields

The metafields applied to the variant.

Tip

To learn about how to create metafields, refer to Create and manage metafields or visit the Shopify Help Center.

Anchor to
next_incoming_date

The arrival date for the next incoming inventory of the variant.

Incoming inventory information is populated by inventory transfers, purchase orders, and third-party apps.

Tip

Use the date filter to format the date.

The values of the variant for each product option.

Example
Output the options of each variant
{% for variant in product.variants -%}
{%- capture options -%}
{% for option in variant.options -%}
{{ option }}{%- unless forloop.last -%}/{%- endunless -%}
{%- endfor %}
{%- endcapture -%}
{{ variant.id }}: {{ options }}
{%- endfor %}

Output

39897499729985: S/Low

39897499762753: S/Medium

39897499795521: S/High

39897499828289: M/Low

39897499861057: M/Medium

39897499893825: M/High

39897499926593: L/Low

39897499959361: L/Medium

39897499992129: L/High

The price of the variant in the currency's subunit.

The value is output in the customer's local (presentment) currency.

For currencies without subunits, such as JPY and KRW, tenths and hundredths of a unit are appended. For example, 1000 Japanese yen is output as 100000.

Tip

Use money filters to output a formatted price.

The parent product of the variant.

Anchor to
quantity_price_breaks

Returns quantity_price_break objects for the variant in the current customer context.

Anchor to
quantity_price_breaks_configured?

Returns true if the variant has any quantity price breaks available in the current customer context. Returns false if it doesn't.

The quantity rule for the variant.

If no rule exists, then a default value is returned.

This rule can be set as part of a B2B catalog.

Note

The default quantity rule is min=1,max=null,increment=1.

Anchor to
requires_selling_plan

Returns true if the variant's product is set to require a selling_plan when being added to the cart. Returns false if not.

Anchor to
requires_shipping

Returns true if the variant requires shipping. Returns false if it doesn't.

Returns true if the variant is currently selected. Returns false if it's not.

Note

The selected variant is determined by the variant URL parameter. This URL parameter is available on product pages URLs only.

Anchor to
selected_selling_plan_allocation

The selected selling_plan_allocation.

If no selling plan is selected, then nil is returned.

Note

The selected selling plan is determined by the selling_plan URL parameter.

Anchor to
selling_plan_allocations

The selling_plan_allocation objects for the variant.

The SKU of the variant.

Anchor to
store_availabilities

The store availabilities for the variant.

The array is defined in only the following cases:

  • variant.selected is true
  • The variant is the product's first available variant. For example, product.first_available_variant or product.selected_or_first_available_variant.

Returns true if taxes should be charged on the variant. Returns false if not.

A concatenation of each variant option, separated by a /.

Example
The variant title
{{ product.variants.first.title }}

Output

S / Low

The unit price of the variant in the currency's subunit.

The price reflects any discounts that are applied to the line item. The value is output in the customer's local (presentment) currency.

For currencies without subunits, such as JPY and KRW, tenths and hundredths of a unit are appended. For example, 1000 Japanese yen is output as 100000.

Note

Unit prices are available only to stores located in the European Union or Switzerland.

Tip

Use the unit_price_with_measurement filter with this property and the variant.unit_price_measurement property to output a formatted unit price with measurement.

To learn about how to display unit prices in your theme, refer to Unit pricing.

Anchor to
unit_price_measurement

The unit price measurement of the variant.

Note

Unit prices are available only to stores located in the European Union or Switzerland.

To learn about how to display unit prices in your theme, refer to Unit pricing.

Tip

Use the unit_price_with_measurement filter with the variant.unit_price property and this property to output a formatted unit price with measurement.

The URL of the variant.

Variant URLs use the following structure:

/products/[product-handle]?variant=[variant-id]

The weight of the variant in grams.

Tip

Use the weight_with_unit filter to format the weight in the store's format.

Use variant.weight_in_unit to output the weight in the unit configured on the variant.

Anchor to
weight_in_unit

The weight of the variant in the unit specified by variant.weight_unit.

Tip

To output this weight, use this property, and the variant.weight_unit property, with the weight_with_unit filter.

Anchor to
weight_unit

The unit for the weight of the variant.

Tip

To output the weight of a variant in this unit, use this property, and the variant.weight_in_unit property, with the weight_with_unit filter.

Deprecated Properties

Anchor to
option1
Deprecated

The value of the variant for the first product option.

If there's no first product option, then nil is returned.

Deprecated

Deprecated. Prefer to use variant.options instead.

Anchor to
option2
Deprecated

The value of the variant for the second product option.

If there's no second product option, then nil is returned.

Deprecated

Deprecated. Prefer to use variant.options instead.

Anchor to
option3
Deprecated

The value of the variant for the third product option.

If there's no third product option, then nil is returned.

Deprecated

Deprecated. Prefer to use variant.options instead.

{
"available": true,
"barcode": "",
"compare_at_price": null,
"featured_image": null,
"featured_media": null,
"id": 39897499729985,
"image": null,
"incoming": false,
"inventory_management": "shopify",
"inventory_policy": "deny",
"inventory_quantity": 5,
"matched": true,
"metafields": {},
"next_incoming_date": null,
"option1": "S",
"option2": "Low",
"option3": null,
"options": [],
"price": "10.00",
"product": {},
"quantity_price_breaks": [],
"quantity_rule": {},
"requires_selling_plan": false,
"requires_shipping": true,
"selected": false,
"selected_selling_plan_allocation": null,
"selling_plan_allocations": [],
"sku": "",
"store_availabilities": [],
"taxable": true,
"title": "S / Low",
"unit_price": null,
"unit_price_measurement": null,
"url": {},
"weight": 500,
"weight_in_unit": 500,
"weight_unit": "g"
}
Was this section helpful?