Open thomascoppein opened 3 years ago
Hi @thomascoppein ,
I don't think it's possible to use more than 2 values for 'where' filter. I also reviewed the official doc and it says so. Please check this out: https://shopify.github.io/liquid/filters/where/
I was thinking about this question, I thought that maybe you can use 'map' filter before 'where'. For example:
{% assign filtered_array = main_array | map: 'sample-category' | where: 'settings.category', 'category-1' %}
Let me know if the answer is helpful or not.
Additionally, it would be beneficial to expand the where
filter so that non-string properties can be passed to it. For example, this will not output a list of available products:
{% assign available_products = collection.products | where: "available", "true" %}
Products we have:
{% for product in available_products -%}
- {{ product.title }}
{%- endfor %}
because product.available
outputs a boolean. Expanding which properties are accepted will also unlock new opportunities for using metafields with the where
filter.
Additionally, it would be beneficial to expand the
where
filter so that non-string properties can be passed to it.
Can't you use where: "available", true
? It doesn't look like there is any coercion of the target_value argument. It looks like it is just an explicit nil
that isn't supported (e.g. where: "optional_property", nil
would behave like where: "optional_property"
, doing the opposite of the intended filter)
Hello, is it possible to dive deeper in a where filter?
For example (this is assigned inside a loop over the blocks):
{% assign filtered_array = main_array | where: 'settings.category', 'category-1' %}
Thanks