Documentation Index
Fetch the complete documentation index at: https://docs.uselayers.com/llms.txt
Use this file to discover all available pages before exploring further.
Layers supports all standard JSONLogic operators. For complete documentation of standard operators, see jsonlogic.com/operations.html.
Accessing data
var
Retrieves a value from the data object. This is the most fundamental operator for accessing product attributes.
{
"var": "_attribute:title"
}
With default value if the field doesn’t exist:
{
"var": ["_attribute:published_at", null]
}
Access the current context (useful in map operations):
Logic and boolean operations
Conditional logic with if-then-else structure.
{
"if": [
{ ">" : [{ "var": "_attribute:price" }, 100] },
"expensive",
"affordable"
]
}
Multiple conditions (if-elseif-else):
{
"if": [
{ "<" : [{ "var": "_attribute:price" }, 50] }, "cheap",
{ "<" : [{ "var": "_attribute:price" }, 100] }, "moderate",
"expensive"
]
}
and
Logical AND operation. Returns true if all conditions are true.
{
"and": [
{ ">" : [{ "var": "_attribute:price" }, 50] },
{ "<" : [{ "var": "_attribute:price" }, 200] }
]
}
Logical OR operation. Returns true if any condition is true.
{
"or": [
{ "var": ["_attribute:published_at", null] },
{ "var": ["_attribute:created_at", null] }
]
}
! (not)
Logical NOT operation. Negates a boolean value.
{
"!": { "var": "_attribute:is_available" }
}
!! (double not)
Converts a value to boolean. Returns true if the value exists and is truthy.
{
"!!": { "var": "_raw:raw.featured_media" }
}
Comparison operations
== (equals)
Loose equality comparison.
{
"==": [
{ "var": "_attribute:status" },
"active"
]
}
=== (strict equals)
Strict equality comparison (type and value must match).
{
"===": [
{ "var": "_attribute:variant_count" },
1
]
}
!= (not equals)
Loose inequality comparison.
{
"!=": [
{ "var": "_attribute:vendor" },
""
]
}
!== (strict not equals)
Strict inequality comparison.
{
"!==": [
{ "var": "_attribute:price_range.from" },
{ "var": "_attribute:price_range.to" }
]
}
> (greater than)
{
">": [
{ "var": "_attribute:price" },
100
]
}
>= (greater than or equal)
{
">=": [
{ "var": "_attribute:inventory_quantity" },
10
]
}
< (less than)
{
"<": [
{ "var": "_attribute:price" },
50
]
}
Between comparison (compound):
{
"<": [50, { "var": "_attribute:price" }, 100]
}
<= (less than or equal)
{
"<=": [
{ "var": "_attribute:discount_percentage" },
25
]
}
Arithmetic operations
+ (addition)
{
"+": [
{ "var": "_attribute:base_price" },
{ "var": "_attribute:tax_amount" }
]
}
- (subtraction)
{
"-": [
{ "var": "_attribute:price" },
{ "var": "_attribute:discount" }
]
}
* (multiplication)
{
"*": [
{ "var": "_attribute:price" },
1.1
]
}
/ (division)
{
"/": [
{ "var": "_attribute:total_sales" },
{ "var": "_attribute:order_count" }
]
}
% (modulo)
{
"%": [
{ "var": "_attribute:inventory_quantity" },
2
]
}
Array operations
map
Transforms each element in an array.
{
"map": [
{ "var": "_raw:raw.variants" },
{ "var": "price" }
]
}
Map with complex transformation:
{
"map": [
{ "var": "_raw:raw.variants" },
{
"if": [
{ "var": "available" },
1,
0
]
}
]
}
filter
Filters an array based on a condition.
{
"filter": [
{ "var": "_raw:raw.variants" },
{ "var": "available" }
]
}
Filter with complex condition:
{
"filter": [
{ "var": "_raw:raw.variants" },
{
">": [
{ "var": "price" },
50
]
}
]
}
reduce
Reduces an array to a single value using an accumulator.
{
"reduce": [
{ "var": "_raw:raw.variants" },
{
"+": [
{ "var": "accumulator" },
{ "var": "current" }
]
},
0
]
}
The reduce operation has access to:
accumulator - The accumulated value
current - The current array element
- The third argument is the initial value for the accumulator
all
Returns true if all elements in an array match the condition.
{
"all": [
{ "var": "_raw:raw.variants" },
{ "var": "available" }
]
}
some
Returns true if any element in an array matches the condition.
{
"some": [
{ "var": "_raw:raw.variants" },
{
">": [
{ "var": "price" },
100
]
}
]
}
none
Returns true if no elements in an array match the condition.
{
"none": [
{ "var": "_raw:raw.variants" },
{
"<": [
{ "var": "inventory_quantity" },
0
]
}
]
}
Checks if a value is in an array or if a substring exists in a string.
Case sensitivity behavior:
- String-in-array matching: Case-insensitive. When checking if a string exists in an array of strings, the comparison ignores case differences.
- Substring-in-string matching: Case-sensitive. When checking if a substring exists within a string, the comparison is case-sensitive.
- Non-string values: Exact matching. Numbers, booleans, and other non-string types use strict equality comparison.
Examples:
Case-insensitive array matching:
{
"in": [
"blue",
["Red", "Blue", "Green"]
]
}
Returns true because “blue” matches “Blue” (case-insensitive).
{
"in": [
"PREMIUM",
{ "var": "_attribute:tags" }
]
}
Returns true if the tags array contains “premium”, “Premium”, “PREMIUM”, or any case variation.
Case-sensitive substring matching:
{
"in": [
"cotton",
{ "var": "_attribute:description" }
]
}
Returns true only if “cotton” (lowercase) appears in the description. “Cotton” or “COTTON” would not match.
Exact matching for non-string values:
{
"in": [
123,
[123, 456, 789]
]
}
Returns true because the number 123 matches exactly.
{
"in": [
"123",
[123, 456, 789]
]
}
Returns false because the string “123” does not match the number 123 (different types).
merge
Merges multiple arrays into a single array.
{
"merge": [
[1, 2, 3],
[4, 5, 6]
]
}
String operations
cat
Concatenates strings.
{
"cat": [
{ "var": "_attribute:vendor" },
" - ",
{ "var": "_attribute:product_type" }
]
}
Whitespace in string literals — including leading and trailing spaces and line breaks (\n) — is preserved when the formula is saved. This lets you build multi-line output directly inside a computed attribute formula, for example when concatenating a descriptive paragraph from multiple fields:
{
"cat": [
"\nFirst line\n",
"Second line\n"
]
}
substr
Extracts a substring. Takes the string, start position, and optional length.
{
"substr": [
{ "var": "_attribute:sku" },
0,
3
]
}
Negative indices count from the end:
{
"substr": [
{ "var": "_attribute:title" },
-5
]
}
Miscellaneous operations
missing
Returns an array of keys that are missing or have falsy values.
{
"missing": [
"_attribute:title",
"_attribute:price",
"_attribute:vendor"
]
}
missing_some
Returns empty array if at least the specified number of keys exist.
{
"missing_some": [
2,
[
"_attribute:published_at",
"_attribute:created_at",
"_attribute:updated_at"
]
]
}