An Equivalent To Is_array() In Liquid?
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.
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.
- → Does anyone know how to solve IP canonicalization with shopify platform?
- → How can I add a featured image from a blog post to my homepage on shopify
- → Shopify - Get list of product from a specific collection
- → Shopify webhooks not wanted
- → Comparing two large files are taking over four hours
- → Need "add to cart" button price to update with correct amount depending on what checkbox is checked
- → How to append a variable inside another vaiable name in liquid html
- → GET /admin/webhooks.json returns an empty array
- → How to give border to to current displaying border
- → Shopify background image
- → Dynamic Attribute Names in Shopify Cart
- → What after added shopify store into shipstation