The product object
The product
object has the following attributes:
product.available
Anchor link to section titled "product.available"Returns true
if a product is available for purchase. Returns false
if 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
Anchor link to section titled "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.
product.compare_at_price
Anchor link to section titled "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
Anchor link to section titled "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
Anchor link to section titled "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
Anchor link to section titled "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
Anchor link to section titled "product.content"Returns the description of the product. Alias for product.description.
product.created_at
Anchor link to section titled "product.created_at"Returns a timestamp for when a product was created in the admin.
product.description
Anchor link to section titled "product.description"Returns the description of the product.
product.featured_image
Anchor link to section titled "product.featured_image"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.
product.featured_media
Anchor link to section titled "product.featured_media"Can be used to render the first piece of media attached to the product.
product.first_available_variant
Anchor link to section titled "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.gift_card?
Anchor link to section titled "product.gift_card?"Returns true
if the product is a gift card.
product.handle
Anchor link to section titled "product.handle"Returns the handle of a product.
product.has_only_default_variant
Anchor link to section titled "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".
Returns the id of the product.
product.images
Anchor link to section titled "product.images"Returns an array of the product's images. Use the image_url
filter to link to the product image on Shopify's content delivery network (CDN).
You can use a for loop to return all of the images associated with a product:
Alternatively, you can add an image_url
filter to the product object to return the product's featured image:
product.media
Anchor link to section titled "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.
For example, you can use a for loop that iterates over each media item associated with a product:
Learn more about adding images, video, and 3D models to themes.
product.metafields
Anchor link to section titled "product.metafields"Returns the product's metafields.
product.options
Anchor link to section titled "product.options"Returns an array of the product's option names.
Use size if you need to determine how many options a product has.
product.options_by_name
Anchor link to section titled "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.
product.options_with_values
Anchor link to section titled "product.options_with_values"Returns an array of the product's options.
product.price
Anchor link to section titled "product.price"Returns the lowest price of all the product's variants. This attribute is the same as product.price_min
.
product.price_max
Anchor link to section titled "product.price_max"Returns the highest price of all the product's variants.
product.price_min
Anchor link to section titled "product.price_min"Returns the lowest price of all the product's variants.
product.price_varies
Anchor link to section titled "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
Anchor link to section titled "product.published_at"Returns a timestamp for when a product was published on a store.
product.requires_selling_plan
Anchor link to section titled "product.requires_selling_plan"Returns true
when all variants of the product have variant.requires_selling_plan
set to true
.
product.selected_variant
Anchor link to section titled "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
.
product.selected_or_first_available_variant
Anchor link to section titled "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_or_first_available_selling_plan_allocation
Anchor link to section titled "product.selected_or_first_available_selling_plan_allocation"Returns a selling_plan_allocation
object based on the following sequential logic:
- If a valid allocation is selected in the URL parameters, then that allocation is returned.
- If no allocation specified in the URL, then the first allocation of an in stock variant is returned.
- 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
Anchor link to section titled "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
Anchor link to section titled "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
Anchor link to section titled "product.selling_plan_groups"An array of selling_plan_group
objects that include the product’s variants.
product.tags
Anchor link to section titled "product.tags"Returns an array of all of the product's tags. The tags are returned in alphabetical order.
product.template_suffix
Anchor link to section titled "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.
product.title
Anchor link to section titled "product.title"Returns the title of the product.
product.type
Anchor link to section titled "product.type"Returns the type of the product.
product.url
Anchor link to section titled "product.url"Returns the relative URL of the product.
product.variants
Anchor link to section titled "product.variants"Returns an array of the product's variants.
product.vendor
Anchor link to section titled "product.vendor"Returns the vendor of the product.