How fallback chains work
When a block doesn’t meet its minimum products safeguard, Layers automatically tries fallback blocks in order:- Primary block is evaluated first
- If results are below minimum, try Fallback 1
- If Fallback 1 also doesn’t meet minimum, try Fallback 2
- Continue until a block meets the minimum or all fallbacks are exhausted
Fallback modes
Each block in a fallback chain has a mode:- Replace: serve the fallback block’s results instead of the primary block’s results.
- Fill remaining: keep the primary block’s results and top them up with products from the fallback block until the minimum is met. Layers removes duplicates and respects the maximum products safeguard. If the primary block uses a diversity cap, Layers applies it across the combined results and places within-cap products before products beyond the cap.
Configuring fallback chains
In the block editor’s numbered Fallback section, click Add branch to create a branch. In its When step, choose Everyone or When conditions match and add conditions if needed. In Then try, click Add block to build the ordered chain, and choose a fallback mode for each block. The editor keeps a live preview on the right as you change the block. Use it to check the recommendations produced by your current settings. Important considerations:- Fallback blocks must be published. Layers skips draft blocks in a chain
- Fallback blocks should have the same anchor type as the primary block
- Fallback blocks must have the same result type as the primary block. A content block can only fall back to other content blocks, and a product block to other product blocks. The dashboard’s fallback builders only offer matching blocks
- Avoid circular references
- Fallback blocks can have their own fallback chains
- Layers prevents infinite loops by tracking visited blocks
- You can mix fallback modes in the same chain
Fallback trees
A fallback tree lets a single block deliver different fallback chains to different visitors. Instead of one ordered list, you define multiple branches, each with its own set of conditions and its own fallback chain. At request time, Layers evaluates each branch in order and uses the chain from the first branch whose conditions match the visitor’s context. Use a fallback tree when you want fallbacks to vary by audience without creating multiple parallel blocks. For example, you might fall back to a “Best Sellers, US” block for shoppers in the United States and a “Best Sellers, EU” block for shoppers in Europe.How tree evaluation works
- Branches are evaluated in the order they appear in the Fallback section
- The first branch with matching conditions wins. Later branches are not evaluated
- A branch with no conditions matches everyone, so it acts as the default. The editor labels it Everyone. Place it last
- The chain inside the matched branch is then evaluated like a normal fallback chain, in order and using each entry’s fallback mode
- If no branch matches and there is no default branch, the block returns no fallback results
Branch conditions
Each branch can target visitors by the same contextual fields used elsewhere on a block: geographic location, customer tags, device type, marketing source, and product attributes when the block has an anchor product. Conditions are combined with AND or OR combinators inside the branch. Conditions are evaluated against the same context object the request was made with, so calls to the Blocks API must passcontext and identity fields for branch matching to work. Without context, only the default branch (if any) will match.
Configuring a fallback tree
In the block editor’s numbered Fallback section, click Add branch once for each branch you need. For each branch:- Under When, choose Everyone or When conditions match, then define the conditions that select this branch.
- Under Then try, add the fallback blocks in order and choose a fallback mode for each one.
Existing blocks that use a flat fallback chain are migrated automatically to a tree with a single default branch. No action is required, and the runtime behavior is unchanged.