# Variant

The Liquid `variant` object and its properties, with examples.

The `variant` object has the following attributes:

## variant.available

Returns `true` if the variant is available for purchase, `false` if not.

A variant is available if `variant.inventory_quantity` is greater than zero or `variant.inventory_policy` is set to `continue`. A variant without `variant.inventory_management` also counts as available.

## variant.barcode

Returns the barcode of the variant.

## variant.compare_at_price

Returns the variant's compare-at price.

Use a [money filter](https://developer.versacommerce.de/articles/liquid-filters-money-filters) to return the value in a money format.

## variant.featured_media

Returns the first media item attached to the variant.

## variant.id

Returns the unique ID of the variant.

## variant.image

Returns the image object attached to the variant.

```liquid
{{ variant.image.src }}
```

```text
/products/red-shirt.jpeg
```

## variant.incoming

Returns `true` if the variant has incoming stock.

## variant.inventory_management

Returns the inventory tracking service of the variant.

## variant.inventory_policy

Returns whether the variant can be sold when it is out of stock. Possible values:

- `continue`: keep selling when the variant is out of stock.
- `deny`: stop selling when the variant is out of stock.

## variant.inventory_quantity

Returns the inventory quantity of the variant.

## variant.matched

Returns whether the variant was matched by a storefront filter: `true` if it matches, `false` if not.

## variant.next_incoming_date

Returns the date when the next incoming stock arrives.

## variant.options

Returns an array of the variant's product option values.

```liquid
{% for option in variant.options %}
  - {{ option }}
{% endfor %}
```

```text
- Red
- Small
- Wool
```

## variant.option1

Returns the value of the variant's first product option.

## variant.option2

Returns the value of the variant's second product option.

## variant.option3

Returns the value of the variant's third product option.

## variant.price

Returns the price of the variant. Use a [money filter](https://developer.versacommerce.de/articles/liquid-filters-money-filters) to return the value in a money format.

## variant.product

Returns the parent [product object](https://developer.versacommerce.de/articles/liquid-objects-product).

## variant.requires_shipping

Returns `true` if the variant requires shipping.

## variant.requires_selling_plan

Returns `true` if the variant requires a selling plan when it is added to the cart. VersaCommerce currently has no selling plans, so this is `false`.

## variant.selected

Returns `true` if the variant is currently selected. The selected variant is based on the `variant` URL parameter.

## variant.selected_selling_plan_allocation

Returns a `selling_plan_allocation` object based on the `selling_plan` URL parameter. VersaCommerce currently has no selling plans, so this returns `nil`.

## variant.selling_plan_allocations

An array of `selling_plan_allocation` objects available for the variant. VersaCommerce currently has no selling plans, so this array is empty.

## variant.sku

Returns the SKU of the variant.

## variant.store_availabilities

Returns an array of [store_availability](https://developer.versacommerce.de/articles/liquid-objects-storeavailability) objects in these cases:

- [variant.selected](#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`.

## variant.taxable

Returns `true` if taxes are charged for the variant, `false` if not.

## variant.title

Returns all product option values of the variant, joined by `/`.

```liquid
<!-- If the variant's option1, option2 and option3 are "Red", "Small", "Wool" -->
{{ variant.title }}
```

```text
Red / Small / Wool
```

## variant.unit_price

Returns the unit price of the product variant. The price reflects any discounts applied to the line item.

## variant.unit_price_measurement

Returns a [unit_price_measurement object](https://developer.versacommerce.de/articles/liquid-objects-unitpricemeasurement) for the product variant.

## variant.url

Returns a URL that is unique to a single product variant. The [variant ID](#variant-id) is used as the unique identifier.

```liquid
{{ variant.url }}
```

```text
/products/t-shirt?variant=12345678
```

## variant.weight

Returns the weight of the variant in grams. Use the [weight_with_unit](https://developer.versacommerce.de/articles/liquid-filters-additional-filters#weightwithunit) filter to convert it to your shop's weight format or the weight unit configured for the variant.

## variant.weight_unit

Returns the weight unit configured for the variant. Works well with the `weight_in_unit` attribute and the [weight_with_unit](https://developer.versacommerce.de/articles/liquid-filters-additional-filters#weightwithunit) filter.

## variant.weight_in_unit

Returns the product weight converted to the unit configured for the variant. Works well with the `weight_unit` attribute and the [weight_with_unit](https://developer.versacommerce.de/articles/liquid-filters-additional-filters#weightwithunit) filter.


## More properties

VersaCommerce also provides these properties on the `variant` object:

| Properties | Returns |
|---|---|
| `quantity_rule`, `selected_option_value_ids` | Quantity rules and resolved option value IDs |
