Types mean what types of value you want to store in variables.
many languages provide basic data types like integer, float, character many more.
same here in Shopify provide basic data types if your want to store string then it supported also you want to store integer value or floating value.
1) Numbers:
generally use numeric number or real number.
numbers includes integer value and float value.
{% assign a_int = 15 %}
{% assign b_float = 3.146 %}
in first variable a_int is variable which store integer value means numeric value.
in second variable b_float is variable which store real value means decimal value.
2) Boolean:
Boolean means either true or false.
A Boolean variable is a special type of memory in a computer that can only store two values: true or false.
Booleans are usually stored using one byte of memory while text variables use more than one.
These are used in conditions and conditional statements which control how the program will behave.
{% assign a = true %}
{% assign b = false %}
In the above example if you assign a then it returns true if you assign b then it returns false.
3) Nil:
sometimes you forget to assign the value of a variable that time it returns nil value.
Nil is a special empty value that is returned when the Liquid code has no results. It is not a string with the characters “nil”.
generally its works as false statements in controlling statements.
{% if fulfillment.product_numbers %}
There is a tracking number.
{% endif %}
Product number: {{ fulfillment.product_numbers }}
Product number:
in this example, if the product number does not exist so the liquid just returns a nil value.
4) String:
Which are mostly used in Shopify liquid programming
String means a collection of characters enclosed with double quotations.
ex: “Codecrew”
{% assign my_string = “Codecrew” %}
You can check for an empty string by comparing it with the blank object. The blank object represents an empty string.
{% assign my_string = ” %}
{% unless my_string == blank %}
{{ my_string }}
{% endunless %}
5) Array:
The array is the collection of the variable of the same data type that shares a common name.
means array stores the same type of value.
If you want to access the value of the array then you must use For loop.
for example:
{% for the tag in the product.title %}
{{ tag}}
{% endfor %}
<!– if product.title = “clothes”, “books”, “crockery” – – >
{{ product.title[0] }}
{{ product.title[1] }}
{{ product.title[2] }}
Output is:
1 clothes
2 books
3 crockery