Is it possible to use the | where
filter on an array such as a cart line item object to filter by property value.
For example, I would like to find all line items with property._design_id of 123.
As far as I can see you're able to filter array | 'type', 'Coat'
, but not something like array | 'properties._design_id', '123'
.
I am aware that I could alternatively do this with a for loop & if statements, however that's a few more lines of code & I would be able to reuse the array without recomputing each time I needed to use those items.
This currently seems impossible as liquid compares exact keys & values not keys for nested arrays.
Current work around is:
for item in cart.items
if item.properties._design_id === '123'
code...
endif
endfor