Skip to main content

where

array | where: string, string

Filters an array to include only items with a specific property value.

This requires you to provide both the property name and the associated value.

{% assign polina_products = collection.products | where: 'vendor', "Polina's Potent Potions" %}

Products from Polina's Potent Potions:

{% for product in polina_products -%}
- {{ product.title }}
{%- endfor %}

Output

Products from Polina's Potent Potions:

- Blue Mountain Flower
- Crocodile tears
- Draught of Immortality
- Gift Card
- Health potion
- Invisibility potion
- Love Potion
- Mana potion
- Potion beats
- Potion bottle
Anchor to Filter for boolean properties with a `true` value

Filter for boolean properties with a true value

You can filter for items that have a true value for a boolean property. This requires you to provide only the property name.

{% assign available_products = collection.products | where: 'available' %}

Available products:

{% for product in available_products -%}
- {{ product.title }}
{%- endfor %}

Output

Available products:

- Charcoal
- Draught of Immortality
- Dried chamomile
- Gift Card
- Ground mandrake root
- Health potion
- Invisibility potion
- Mana potion
- Potion beats
- Viper venom
- Whole bloodroot
Was this page helpful?