Difference between revisions of "Liquid Template Variables - product"
From Spiffy Stores Knowledge Base
m (→product.images) |
m (→product.images) |
||
Line 73: | Line 73: | ||
== <code>product.images</code> == | == <code>product.images</code> == | ||
− | Returns | + | Returns an array of all the [[Liquid_Template_Variables_-_image|image]] template variables for this product. |
For example, | For example, |
Revision as of 14:55, 6 November 2013
The Liquid template variable product has the following attributes:
Contents
- 1 product.id
- 2 product.handle
- 3 product.title
- 4 product.type
- 5 product.vendor
- 6 product.price
- 7 product.price_min
- 8 product.price_max
- 9 product.price_varies
- 10 product.compare_at_price
- 11 product.compare_at_price_min
- 12 product.compare_at_price_max
- 13 product.compare_at_price_varies
- 14 product.featured_image
- 15 product.images
- 16 product.images_count
- 17 product.description
- 18 product.content
- 19 product.variants
- 20 product.available
- 21 product.collections
- 22 product.tags
- 23 product.url
- 24 product.options
product.id
Returns the unique internal number of the product.
This is normally only for internal usage.
product.handle
This is the product handle. The handle uniquely identifies the product in the URL address.
The handle is usually the product's title in lower case with all blanks replaced by a dash. "Red Hat" would have the handle "red-hat".
product.title
Returns the title of this product.
product.type
Returns the type of this product, for example, "t-shirt" or "garden gnome".
product.vendor
Returns the vendor of this product, such as "Spiffy Stores" or "Acme Tools".
product.price
Returns the price for this product. By default this is the minimum price.
product.price_min
Returns the minimum price for this product.
product.price_max
Returns the minimum price for this product.
product.price_varies
Returns true if the price_min is different from price_max.
product.compare_at_price
Returns the "compare at" price, that is, the recommended retail price for this product. By default this is the minimum "compare at" price.
product.compare_at_price_min
Returns the "compare at" price, that is, the recommended retail price for the least expensive variant of this product.
product.compare_at_price_max
Returns the "compare at" price, that is, the recommended retail price for the most expensive variant of this product
product.compare_at_price_varies
Returns true if the compare_at_price_min is different from compare_at_price_max.
product.featured_image
Returns the featured_image as an image template variable.
When used directly, such as product.featured_image, it returns the relative URL path of the featured image. This is equivalent to using product.featured_image.src.
For example,
<div> <img src="{{ product.featured_image | product_img_url: 'medium' }}" alt="{{ product.featured_image.alt | escape }}" /> </div>
product.images
Returns an array of all the image template variables for this product.
For example,
{% for image in product.images %} {{ image | product_img_url: 'medium' }} {% endfor %}
When used directly, such as image, it returns the relative URL path of the image. This is equivalent to using image.src.
product.images_count
Returns the number of images for this product.
product.description
Returns the description of this product.
product.content
This is an alias of description.
product.variants
Returns a collection of all of this product's variants.
product.available
Returns false if all variants' quantities are zero and their policies are set to "stop selling when sold out".
product.collections
Returns a collection of all collections that this product belongs to.
<ul> {% for collection in product.collections %} <li>{{ collection.title }}</li> {% endfor %} </ul>
product.tags
Returns a list of the product's tags (represented by simple strings).
product.url
The is the relative URL address of the product.
<a href="{{ product.url }}"> <img src="{{ product.featured_image | product_img_url: 'small' }}" /> </a>
product.options
Returns a list of the product's options. This will always be an array of option names, and there is always at least one option. By default, if no options have been defined, the first option will be called 'Title' and this is the name of the product variation.
The number of options can be used to select whether to use multiple option drop-downs in a product page.
{% if product.options.size > 1 %} <!-- The product has more than one option … Display using drop-downs --> {% else %} <!-- The product has only one option … Display using radio buttons --> {% endif %}