The product object

The product object has the following attributes:

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

product.collections

Returns an array of all of the collections that a product belongs to, except any collections that are not available on the sales channel being used.

Input

This product belongs in the following collections:

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

Output

This product belongs in the following collections:

Sale
Shirts
Spring

product.compare_at_price

Returns the lowest compare at price of all the product's variants entered in the Shopify admin. This attribute is similar to product.compare_at_price_min.

If none of the product variants have a value for compare at price, product.compare_at_price will return nil.

product.compare_at_price_max

Returns the highest compare at price of all the product's variants entered in the Shopify admin.

If none of the product variants have a value for compare at price, product.compare_at_price_max will return 0.

product.compare_at_price_min

Returns the lowest compare at price of all the product's variants entered in the Shopify admin.

If none of the product variants have a value for compare at price, product.compare_at_price_min will return 0.

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.

product.content

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

product.created_at

Returns a timestamp for when a product was created in the admin.

Input

{{ product.created_at }}

Output

2019-11-01 05:56:37 -0400

product.description

Returns the description of the product.

Returns an image object of the product's featured image. The first image for each product is known as the featured, or main, image.

Referencing just product.featured_image will return the relative URL of the image.

Input

URL: {{ product.featured_image }}
Aspect ratio: {{ product.featured_image.aspect_ratio }}
URL: {{ product.featured_image.src }}

Output

URL: products/name.png
Aspect ratio: 1.0
URL: products/name.png

Can be used to render the first piece of media attached to the product.

product.first_available_variant

Returns the variant object of the first product variant that is available for purchase. In order for a variant to be available, its variant.inventory_quantity must be greater than zero or variant.inventory_policy must be set to continue. A variant with no inventory_policy is considered available.

product.handle

Returns the handle of a product.

product.has_only_default_variant

Returns true if the product only has the default variant. This lets you determine whether to show a variant picker in your product forms.

Products that don't have customized variants have a single default variant with its "Title" option set to "Default Title".

{% if product.has_only_default_variant %}
  <input name="id" value="{{ variant.id }}" type="hidden">
{% else %}
  <select name="id">
    {% for variant in product.variants %}
      <option value="{{ variant.id }}">{{ variant.title }}</option>
    {% endfor%}
  </select>
{% endif %}

product.id

Returns the id of the product.

product.images

Returns an array of the product's images. Use the img_url filter to link to the product image on Shopify's content delivery network (CDN).

Input

{{ product | img_url }}

Output

https://cdn.shopify.com/s/files/1/1183/1048/products/boat-shoes_small.jpeg?v=1459175177

product.options

Returns an array of the product's option names.

Input

{% for option in product.options %}
    {{ option }}
{% endfor %}

Output

Color Size Material

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

Input

{{ product.options.size }}

Output

3

product.options_by_name

Allows direct access to a product's options by their name. The object keys of options_by_name are case-insensitive.

Input

<label>
  Color
  <select>
    {% for color_option in product.options_by_name['Color'].values %}
      <option>{{ color_option }}</option>
    {% endfor %}
  </select>
</label>

Output

<label>
  Color
  <select>
    <option>Red</option>
    <option>Green</option>
  </select>
</label>

product.options_with_values

Returns an array of the product's options.

Input

{% for product_option in product.options_with_values %}
  <label>
    {{ product_option.name }}
    <select>
      {% for value in product_option.values %}
        <option {% if product_option.selected_value == value %}selected{% endif %}>
          {{ value }}
        </option>
      {% endfor %}
    </select>
  </label>
{% endfor %}

Output

<label>
  Color
  <select>
    <option selected>Red</option>
    <option>Green</option>
  </select>
</label>

product.price

Returns the lowest price of all the product's variants. This attribute is the same as product.price_min.

product.price_max

Returns the highest price of all the product's variants.

product.price_min

Returns the lowest price of all the product's variants.

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.

product.published_at

Returns a timestamp for when a product was published on a store.

Input

{{ product.published_at }}

Output

2019-11-01 05:56:37 -0400

product.selected_variant

Returns the variant object of the currently-selected variant if there is a valid ?variant= parameter in the URL. Returns nil if there is not.

Input

<!-- URL = myshop.myshopify.com/products/shirt?variant=124746062 -->
{{ product.selected_variant.id }}

Output

124746062

product.selected_or_first_available_variant

Returns the variant object of the currently-selected variant if there is a valid ?variant= query parameter in the URL. If there is no selected variant, the first available variant is returned. In order for a variant to be available, its variant.inventory_quantity must be greater than zero or variant.inventory_policy must be set to continue. A variant with no inventory_management is considered available.

product.tags

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

Input

{% for tag in product.tags %}
  {{ tag }}
{% endfor %}

Output

new
leather
sale
special

product.template_suffix

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

Input

<!-- on product.wholesale.liquid -->
{{ product.template_suffix }}

Output

wholesale

product.title

Returns the title of the product.

product.type

Returns the type of the product.

product.url

Returns the relative URL of the product.

Input

{{ product.url }}

Output

/products/awesome-shoes

product.variants

Returns an array of the product's variants.

product.vendor

Returns the vendor of the product.