Liquid Template Variables - variant
From Spiffy Stores Knowledge Base
The Liquid template variable variant has the following attributes:
Contents
- 1 variant.id
- 2 variant.title
- 3 variant.price
- 4 variant.compare_at_price
- 5 variant.discount
- 6 variant.available
- 7 variant.inventory
- 8 variant.inventory_quantity
- 9 variant.inventory_management
- 10 variant.inventory_policy
- 11 variant.option1
- 12 variant.option2
- 13 variant.option3
- 14 variant.weight
- 15 variant.sku
- 16 variant.barcode
- 17 variant.metafields
- 18 variant.requires_shipping
- 19 variant.taxable
- 20 variant.free_shipping
- 21 variant.ship_separately
- 22 variant.featured_image
- 23 variant.image
variant.id
Returns the unique internal number of the variant.
This is normally only for internal usage.
variant.title
Returns the title of this variant. A variant title is usually a short value that distinguishes it from the other variants of the product. For example, it could be something like "S", "M" or "L" for clothes sizes or "red" or "green" for product colours.
variant.price
Returns the variant's price.
variant.compare_at_price
Returns the recommend retail price for this product variant. This may also be the price of the variant before being discounted or put on sale.
variant.discount
Returns the amount of a variant's discount. If the variant cannot be discounted, then 0 will be returned. A variant can only be discounted if it is determined to be eligible by a Shopping Cart Discount rule.
variant.available
Returns true if the variant is available and not sold out.
This value can be used to either hide variants that are not available for sale, or to mark them as "Sold Out".
Variants which are not available should not be placed in the shopping cart.
For example:
{% if variant.available == true %} We currently have {{ variant.inventory_quantity }} in stock. {% else %} Sold out! {% endif %}
variant.inventory
Return true if this variant has inventory management enabled.
variant.inventory_quantity
Returns the number of this variant that are in stock. Note that this value will only be valid if variant.inventory
is true.
variant.inventory_management
Return the variant's inventory management service. Typically this will be 'spiffy', if the inventory is being managed by your store.
variant.inventory_policy
Return the variant's inventory policy that will be applied when an item is sold out. The available values are 'deny', 'continue' or 'archive'.
If the policy is 'deny', then no further orders will be allowed until the item is back in stock.
If the policy is 'continue', then further orders will be permitted and the item will be back-ordered.
If the policy is 'archive', then no further orders will be allowed and the product will be hidden and will no longer be displayed in the store.
variant.option1
Returns the value of option 1 for the given variant.
variant.option2
Returns the value of option 2 for the given variant.
variant.option3
Returns the value of option 3 for the given variant.
variant.weight
Returns the weight of the variant. This will always be in grams. To display the value according to your store's weight system, use the weight_with_unit filter.
This product weights {{ product.variants.first.weight | weight_with_unit }}
variant.sku
Returns the variant's SKU.
variant.barcode
Return the variant's barcode.
variant.metafields
Return the metafields for the variant.
Metafields can only be managed using the Spiffy Stores API.
variant.requires_shipping
Return true if this variant needs to be shipped. Typically physical goods will need shipping, whereas services or digital items will not need shipping.
variant.taxable
Return true is this variant is taxable. Various tax jurisdictions often specify specific items that are exempt from taxation. This setting can be used highlight which items do not attract tax.
variant.free_shipping
Return true if this variant is eligible for free shipping.
variant.ship_separately
Return true if this variant must be shipped separately because it requires special handling or is large and bulky and cannot be shipping together with other items.
variant.featured_image
Return the image associated with the variant, if it has been defined.
{{ variant.featured_image.src }} ==> 'products/1504_cute_dog.jpg'
variant.image
This is an alias for the variant.featured_image function.