Variant
From Shopify Wiki
Variants represent variations, or types of a single product. You can access a product’s variants with product.variants.
Product Variants have the following attributes:
Contents |
variant.id
Returns the variant’s unique id.
variant.title
Returns the concatenation of all the variant's option values, joined by " / ". For example, if your variant has option1 as "Large", option2 as "Red", then variant.title will return "Large / Red". If a product has just single option, then the title is simply the value of option1.
variant.price
Returns the variant’s price.
variant.compare_at_price
Returns the variant’s recommended retail price.
variant.available
Returns whether the variant is available for sale or not.
Depending on your preferences, we suggest you hide variants that are not for sale anymore OR mark them as sold out.
If variant.available returns false, this item must not be added to the cart.
Example:
{% if variant.available == true %}
We currently have {{ variant.inventory_quantity }} in stock.
{% else %}
Sold out!
{% endif %}
variant.inventory_management
Returns the variant’s inventory tracking service, e.g. shopify or shipline, or simply '' (an empty string) when the inventory stock level is not being tracked at all.
variant.inventory_quantity
Returns how many of this variants are in stock for this shop.
Note that this value will only be accurate if variant.inventory_management reports that the variant’s inventory stock level is being tracked.
variant.weight
Returns the weight of the variant. This will always be in metric grams. For displaying it according to your weight system (metric/imperial) please run the variable through the weight_with_unit filter.
This product weighs {{ product.variants.first.weight | weight_with_unit }}
variant.sku
Returns the variant's SKU.
variant.option1
Returns the value of option1 for given variant
variant.option2
If a product has a second option defined, then returns the value of this variant's option2.
variant.option3
If a product has a third option defined, then returns the value of this variant's option3.
