Difference between revisions of "Liquid Template Variables - variant"

From Spiffy Stores Knowledge Base

Line 18: Line 18:
  
 
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.
 
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.
 +
 +
== <code>variant.discount</code> ==
 +
 +
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.
  
 
== <code>variant.available</code> ==
 
== <code>variant.available</code> ==

Revision as of 14:16, 26 March 2009

The liquid template variable variant has the following attributes:

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

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.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.