Files
liquid/_posts/objects/product.md
2014-07-23 11:17:11 -04:00

7.4 KiB

layout, title, nav
layout title nav
default product
group
Liquid Variables

product

The product object has the following attributes:

{% table_of_contents %}

{% anchor_link "product.available", "product-available" %}

Returns true if a product is available for purchase. Returns falseif all of the products variants' inventory_quantity values are zero or less, and their inventory_policy is not set to "Allow users to purchase this item, even if it is no longer in stock."

{% anchor_link "product.collections", "product-collections" %}

Returns an array of all of the collections a product belongs to.

Input

{% highlight html %}{% raw %} This product belongs in the following collections:

{% for collection in product.collections %} {{ collection.title }} {% endfor %} {% endraw %}{% endhighlight %}

Output

{% highlight html %}{% raw %} This product belongs in the following collections:

Sale Shirts Spring {% endraw %}{% endhighlight %}

{% anchor_link "product.compare_at_price_max", "product-compare_at_price_max" %}

Returns the highest compare at price. Use one of the money filters to return the value in a monetary format.

{% anchor_link "product.compare_at_price_min", "product-compare_at_price_min" %}

Returns the lowest compare at price. Use one of the money filters to return the value in a monetary format.

{% anchor_link "product.compare_at_price_varies", "product-compare_at_price_varies" %}

Returns true if the compare_at_price_min is different from the compare_at_price_max. Returns false if they are the same.

{% anchor_link "product.content", "product-content" %}

Returns the description of the product. Alias for product.description.

{% anchor_link "product.description", "product-description" %}

Returns the description of the product.

{% anchor_link "product.featured_image", "product-featured_image" %}

Returns the relative URL of the product's featured image.

{% anchor_link "product.handle", "product-handle" %}

Returns the handle of a product.

{% anchor_link "product.id", "product-id" %}

Returns the id of the product.

{% anchor_link "product.images", "product-images" %}

Returns an array of the product's images. Use the product_img_url filter to link to the product image on Shopify's Content Delivery Network.

Input

{% highlight html %}{% raw %} {% for image in product.images %} {% endfor %} {% endraw %}{% endhighlight %}

Output

{% highlight html %}{% raw %} {% endraw %}{% endhighlight %}

{% anchor_link "product.options", "product-options" %}

Returns an array of the product's options.

Input

{% highlight html %}{% raw %} {% for option in product.options %} {{ option }} {% endfor %} {% endraw %}{% endhighlight %}

Output

{% highlight html %}{% raw %} Color Size Material {% endraw %}{% endhighlight %}

Use size if you need to determine how many options a product has.

Input

{% highlight html %}{% raw %} {{ product.options.size }} {% endraw %}{% endhighlight %}

Output

{% highlight html %}{% raw %} 3 {% endraw %}{% endhighlight %}

{% anchor_link "product.price", "product-price" %}

Returns the price of the product. Use one of the money filters to return the value in a monetary format.

{% anchor_link "product.price_max", "product-price_max" %}

Returns the highest price of the product. Use one of the money filters to return the value in a monetary format.

{% anchor_link "product.price_min", "product-price_min" %}

Returns the lowest price of the product. Use one of the money filters to return the value in a monetary format.

{% anchor_link "product.price_varies", "product-price_varies" %}

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

{% anchor_link "product.tags", "product-tags" %}

Returns an array of all of the product's tags. The tags are returned in alphabetical order.

Input

{% highlight html %}{% raw %} {% for tag in product.tags %} {{ tag }} {% endfor %} {% endraw %}{% endhighlight %}

Output

{% highlight html %}{% raw %} new leather sale special {% endraw %}{% endhighlight %}

{% anchor_link "product.template_suffix", "product-template_suffix" %}

Returns the name of the custom product template assigned to the product, without the product. prefix nor the .liquid suffix. Returns nil if a custom template is not assigned to the product.

Input

{% highlight html %}{% raw %} {{ product.template_suffix }} {% endraw %}{% endhighlight %}

Output

{% highlight html %}{% raw %} wholesale {% endraw %}{% endhighlight %}

{% anchor_link "product.title", "product-title" %}

Returns the title of the product.

{% anchor_link "product.type", "product-type" %}

Returns the type of the product.

{% anchor_link "product.url", "product-url" %}

Returns the relative URL of the product.

Input

{% highlight html %}{% raw %} {{ product.url }} {% endraw %}{% endhighlight %}

Output

{% highlight html %}{% raw %} /products/awesome-shoes {% endraw %}{% endhighlight %}

{% anchor_link "product.variants", "product-variants" %}

Returns an array the product's variants.

{% anchor_link "product.vendor", "product-vendor" %}

Returns the vendor of the product.