Skip to main content

plus

Adds a number to another number.

minus

Subtracts a number from another number.

times

Multiplies a number by another number.

divided_by

Divides a number by another number. The result is the string obtained by JavaScript .toString() of the result number.
In JavaScript, float and integer shares the same type number and we cannot tell the difference. For example:
You’ll need to pass another integerArithmetic argument to enforce integer divide:

modulo

Returns the remainder of a division operation.

abs

Liquid filter that returns the absolute value of a number.
abs will also work on a string that only contains a number:

at_least

Limits a number to a minimum value.

at_most

Limits a number to a maximum value.

ceil

Rounds the input up to the nearest whole number. LiquidJS tries to convert the input to a number before the filter is applied.
Here the input value is a string:

floor

Rounds the input down to the nearest whole number. LiquidJS tries to convert the input to a number before the filter is applied.
Here the input value is a string:

round

Rounds a number to the nearest integer or, if a number is passed as an argument, to that number of decimal places.

sum

Computes the sum of all the numbers in an array. An optional argument specifies which property of the array’s items to sum up. In this example, assume the object cart.products contains an array of all products in the cart of a website. Assume each cart product has a qty property that gives the count of that product instance in the cart. Using the sum filter we can calculate the total number of products in the cart.