Product

From Shopify Wiki

Jump to: navigation, search

The liquid variable _product_ has the following attributes:

Contents

product.id

Returns the id of this product

product.title

Returns the title of this product

product.handle

Returns the handle of this product

product.type

Returns the type of this product, e.g. "snowboard", "headphones"

product.vendor

Returns the vendor of this product, e.g. "Sony", "Apple"

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

Returns a "compare at" price, e.g. recommended retail price for the least expensive variant of this product.

product.price_max

Returns the maximum price for this product.

product.compare_at_price_max

Returns a "compare at" price, e.g. recommended retail price for the most expensive variant of this product.

product.price_varies

Returns true if the product's variants have varying prices. Returns false if all variants have the same price.

In this example we will show the price of the product if all variants have the same price but will show the range of prices if they differ:

 Price: 
 {% if product.price_varies %} 
    between {{ product.price_min | money }} to {{ product.price_max | money }} 
 {% else %}
   {{ product.price_min | money }}
 {% end %}

product.compare_at_price_varies

Returns true if the compare_at_price_min is different from compare_at_price_max

product.url

Returns the url of this product. You need this for hyperlinking to this product's detail page from anywhere else in the store

<a href="{{product.url}}"><img src="{{ product.featured_image | product_img_url: 'small' }}" /></a>

product.featured_image

Returns the filename with a relative path of the featured image.

product.images

Returns a collection of all image filenames for this product.

product.description

Returns the description of this product.

product.content

Alias of product.description.

product.variants

Returns a collection of all of this product's variants. See variant.

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 list of collections a product is listed in.

product.tags

Returns a list of the product's tags (represented by simple strings).


product.options

Returns a list of the product's options. By default, there is always at least one option, but there can be up to three.

You can do a check to see how many Options a product may have by using the size filter. For example, you can do:

   {% if product.options.size > 1 %}         
       Display the variants as dropdowns.
   {% else %}
       Display the variants as options.
   {% endif %}
Personal tools