0
votes

Is there a way to test whether something is an array or not in Liquid? Or if an array is empty? Or if a variable is defined but empty?

I'm trying to write something for Shopify that will only show a particular metafield if the product doesn't have any variants, but there doesn't seem to be any way of testing if product.variants has any content in Liquid.

1

1 Answers

0
votes

Turns out you can use .size to check the length of a string or the size of an array. For example, if product.variants.size > 1.

Read about Array Filters in Liquid.