You are currently viewing How to Use all_products object in a Shopify Theme

How to Use all_products object in a Shopify Theme

We can achieve this by using all_products. Here’s a quick example:

{{ all_products["green-tea"].title }}

Liquid Handles

The handle is used to access the attributes of a Liquid object. By default, it is the object’s title in lowercase with any spaces and special characters replaced by hyphens (-). Every object in Liquid (product, collection, blog, menu) has a handle. For example, a page with the title “About Us” can be accessed in Liquid via its handle “about-us”.

In the above example, we have a handle of  green-tea  which represents the product available at yourstore.com/products/green-tea . We follow that by .title. When rendered, this will output the title of the product with the handle of green-tea.

Using all_products we can access any property of the product:

all_products["green-tea"].available
all_products["green-tea"].collections
all_products["green-tea"].compare_at_price_max
all_products["green-tea"].compare_at_price_min
all_products["green-tea"].compare_at_price_varies
all_products["green-tea"].content
all_products["green-tea"].description
all_products["green-tea"].featured_image
all_products["green-tea"].first_available_variant
all_products["green-tea"].handle
all_products["green-tea"].id
all_products["green-tea"].images
all_products["green-tea"].image
all_products["green-tea"].options
all_products["green-tea"].price
all_products["green-tea"].price_max
all_products["green-tea"].price_min
all_products["green-tea"].price_varies
all_products["green-tea"].selected_variant
all_products["green-tea"].selected_or_first_available_variant
all_products["green-tea"].tags
all_products["green-tea"].template_suffix
all_products["green-tea"].title
all_products["green-tea"].type
all_products["green-tea"].url
all_products["green-tea"].variants
all_products["green-tea"].vendor

Leave a Reply