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

Returns a mixed array of a product's associated media, sorted by date added. You can use media filters to generate URLs and model-viewer tags so media is rendered on the product page.

Input

{{ product.media }}

Output

products/boat-shoes.jpgVideoDropExternalVideoDrop

The product.media object is used to create a for loop that iterates over each media item associated with a product.

{% for media in product.media %}
  {% include 'media' %}
{% endfor %}

Learn more about adding images, video, and 3D models to themes.

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

Returns true when all variants of the product have variant.requires_selling_plan set to true.

product.selected_variant

Returns the variant object of the selected variant. The selected variant is based on the URL parameter variant.

If there is no selected variant, then this property returns nil.

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 selected variant. The selected variant is based on the URL parameter variant.

If there is no selected variant, then the first available variant is returned. 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 also considered available.

product.selected_of_first_available_selling_plan_allocation

Returns a selling_plan_allocation object based on the following sequential logic:

  1. If a valid allocation is selected in the URL parameters, then that allocation is returned.
  2. If no allocation specified in the URL, then the first allocation of an in stock variant is returned.
  3. If no variants are in stock, then the first allocation on the first variant is returned.

If the product doesn't have selling plans, then this property returns nil.

product.selected_selling_plan

Returns the selling_plan object based on the URL parameter selling_plan and a value of a selling plan's ID.

For example, when given the URL parameter ?selling_plan=789, the property returns the selling_plan object with ID 789.

product.selected_selling_plan_allocation

Returns the selling_plan_allocation object based on URL parameters identifying a selling plan and variant.

For example, when given URL parameters ?variant=12345&selling_plan=8765, the property returns the allocation for the variant object with ID 12345 and the selling plan with ID 8765.

product.selling_plan_groups

An array of selling_plan_group objects, which includes the product’s variants.

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.