Difference between revisions of "Liquid Template Variables - variant"

From Spiffy Stores Knowledge Base

Line 60: Line 60:
  
 
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.
 
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.
 +
 +
== <code>variant.option1</code> ==
 +
 +
Returns the value of option 1 for the given variant.
 +
 +
== <code>variant.option2</code> ==
 +
 +
Returns the value of option 2 for the given variant.
 +
 +
== <code>variant.option3</code> ==
 +
 +
Returns the value of option 3 for the given variant.
  
 
== <code>variant.weight</code> ==
 
== <code>variant.weight</code> ==

Revision as of 13:15, 2 July 2014

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

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.