Wizards
Build your own step-by-step configurator on the same engine the admin wizard builder and the Bolder wizard components use.
A wizard is data (steps, fields, conditions, pricing) that merchants edit in the admin wizard builder. The SDK exports the engine that evaluates it as wizard, so you can build any UI on top and get the same visibility and prices as the server.
import { wizard } from 'bolder-storefront'
The config format (steps, fields, conditions, pricing, paths,
quantity) is documented in Step wizard. Read that first.
Example
You keep the answers in your own state. entry is one product entry of the wizard config.
const answers = wizard.buildInitialAnswers(entry.steps) // defaults per field id
answers.width = 120
const ctx = wizard.withQuantity(answers, 2) // adds the reserved `quantity`
const steps = wizard.activeSteps(entry, ctx) // steps whose visibleIf matches
const fields = wizard.visibleFields(steps[0], ctx) // fields to show on a step
wizard.subtotal(entry, ctx) // price per unit
wizard.finalTotal(entry, ctx) // after the discount rate
wizard.priceBreakdown(entry, ctx) // [{ label, amount }]
Prices are per unit. Multiply by the quantity yourself, or send the items to the pricing endpoint (Server-side pricing) and charge what it returns. The client total is for display only.
Functions
All take the product entry as config and the answers (with quantity, see withQuantity) as answers.
| Function | Returns |
|---|---|
buildInitialAnswers(steps) |
Answers object with each field’s default (or null). |
withQuantity(answers, quantity) |
Copy of the answers with the reserved quantity (default 1). |
activeSteps(config, answers) |
Steps whose visibleIf matches. |
visibleFields(step, answers) |
Fields of a step whose visibleIf matches. |
visibleRows(step, answers) |
Recap rows of a summary step that match. |
catalogOptions(config, field, answers) |
Options of a catalog field (honours groupBy and extraOptions). |
dependentSelectOptions(field, answers) |
Choices of a dependentSelect for the parent’s answer. |
matches(condition, answers) |
Whether a condition (object or list) holds. |
subtotal, discountAmount, finalTotal (config, answers) |
Per-unit amounts. |
priceBreakdown(config, answers) |
Rows { label, amount } grouped by factor label. |
factorAmount(config, factor, answers) |
Amount of a single pricing factor. |
pathPrice(config, path, answers) |
Price of a path on a summary step. |
renderMessage(config, template, path, answers) |
Fills {{price}}, {{total}}, {{discount}}. |
formatCurrency(config, amount) |
Amount formatted with the entry’s pricing.locale and currency. |
fieldDisplayValue(config, fieldId, answers, labels) |
Human label of an answer, or null. |
defaultLabels() |
The default interface strings. |
RESERVED_FIELD_IDS |
Ids a field can’t use (['quantity']). |
Where the config comes from
There is no public endpoint to read a saved wizard yet: ship the config with your frontend (export it from the builder or keep it in your repo). The pricing endpoint reads the saved wizard on the server, so the two have to match.
Source of truth for the engine: src/shops/wizard-core.js in bolder-blocks, vendored into the SDK with scripts/vendor_wizard_core.sh.