Types of Data

There are different types of data used in Liquid.

String is text.

Boolean is true of false.

Integers are numbers.

Floats are fractions or decimal numbers.

An array is a group of data of the previous types of data. Shopify uses arrays to hold objects like products, articles, and collections. An object is a type of data that holds different properties. For example, a product can have a price, title, featured image, array of variants, etc. 

The properties can be used with a dot notation.

Or with an array notation.

Both using the name of the property we would like to get.

Making an array.

To make an array, you will have to make a string with a common separator between values. Finally, make an array using the split filter. If you use the split filter to make a group of other data besides strings, the filter will change all the variables to string values. Number values can still be interpreted and compared to numbers as long as the comparison is to a number string. Must make sure all values are numbers, since you will get different out comes otherwise. The same goes for an array of boolean values, the group of data must all be a boolean and can only be compared with string boolean values. You must use {% if current_variable == "true" %} because using {% if current_variable %} shorthand notation will always result in true. This is due to the variables being changed to strings.

Joe Pichardo | Shopify Developer

About Joe Pichardo

Joe Pichardo is a Shopify Developer creating themes and apps to help other programmers succeed on the ecommerce platform.

Having trouble? Ask for help.