webx-ui / module-configurator
A product configurator for the WebX UI admin panel: steps of options and sizes built without code, visibility rules, an area formula and a price with its breakdown counted on the server, drafts and versions, and MCP tools to build one end to end.
Requires
- php: ^8.4
- illuminate/contracts: ^13.0
- illuminate/database: ^13.0
- illuminate/http: ^13.0
- illuminate/support: ^13.0
- illuminate/view: ^13.0
- webx-ui/cache: ^0.87.0
- webx-ui/localization: ^0.87.0
- webx-ui/mcp: ^0.87.0
- webx-ui/module-admin: ^0.87.0
- webx-ui/module-media: ^0.87.0
Requires (Dev)
- orchestra/testbench: ^11.0
- phpunit/phpunit: ^12.0 || ^13.0
- webx-ui/module-auth: ^0.87.0
- webx-ui/module-blocks: ^0.87.0
- webx-ui/module-inbox: ^0.87.0
- webx-ui/module-settings: ^0.87.0
- webx-ui/themes: ^0.87.0
- webx-ui/widgets: ^0.87.0
Suggests
- webx-ui/module-blocks: The offered block `configurator`: a configurator put on any page from the panel, with its heading and where it starts.
- webx-ui/module-inbox: The request form a configurator sends its configuration to, priced again on the server; the demo makes one.
- webx-ui/module-settings: The messengers of the site's contacts, beside the request button.
- webx-ui/themes: With a theme, the configurator gets its base look on site tokens (resources/theme/configurator.css).
Provides
None
Conflicts
None
Replaces
None
README
A product configurator as a section of the WebX UI admin panel: steps of options and sizes built without code, rules for what is shown when, an area formula, and a price with its breakdown counted on the server.
A visitor chooses a construction, enters the sizes, picks the options, sees a picture and the price, and sends a request with the whole configuration. The module knows nothing about any product: shower enclosures, doors, partitions, furniture, windows, fences and print are all one schema document.
This package stores, checks and prices a configurator, keeps its drafts and versions, and answers
the panel's editor — the npm package @webx-ui/module-configurator, with its constructor, live
preview and JSON mode — and the MCP tools; it installs the demo too. On the site it prints the
configurator (a block or <x-webx-configurator>) and puts the configuration, priced again on the
server, into a request of the inbox.
Requirements
- PHP 8.4+, Laravel 13
webx-ui/module-admin,webx-ui/module-media,webx-ui/localization,webx-ui/mcpwebx-ui/module-inboxfor the request form,webx-ui/module-blocksfor the block,webx-ui/themesfor the base look,webx-ui/module-settingsfor the messengers — suggested
Install
composer require webx-ui/module-configurator
php artisan migrate
php artisan webx:demo --module=configurators # optional: the shower enclosure demo
Permissions: configurators.view, configurators.manage.
The schema
A configurator is one JSON document. The short version:
{
"version": 1,
"currency": "UAH",
"pricing": { "round": 100 },
"initial": { "construction": "corner" },
"discount": { "percent": 10, "until": "2026-11-30", "label": "Autumn" },
"steps": [
{
"key": "construction",
"type": "cards",
"label": "Construction",
"options": [
{
"value": "corner",
"label": "Corner enclosure",
"image": "media/ab/cd/corner.webp",
"area": "(w+d)*h/1e6",
"price": { "fixed": 8000, "perM2": 4420 },
"defaults": { "h": 2000, "w": 900, "d": 900 }
}
]
},
{
"key": "size",
"type": "dimensions",
"title": "Sizes",
"fields": [
{ "key": "h", "label": "Height", "unit": "mm", "min": 1300, "max": 2400, "step": 50 },
{ "key": "w", "label": "Width", "unit": "mm", "min": 600, "max": 1600, "step": 50 },
{
"key": "d",
"label": "Depth",
"unit": "mm",
"min": 600,
"max": 1600,
"when": { "construction": ["corner"] }
}
]
},
{
"key": "hardware",
"type": "swatches",
"label": "Hardware",
"options": [
{ "value": "chrome", "label": "Chrome", "swatch": "#c9ced3" },
{
"value": "gold",
"label": "Gold",
"swatch": "linear-gradient(135deg, #b8862b, #f3d27a)",
"price": { "percent": 12 }
}
]
}
]
}
- Step types:
cards(a picture each),swatches(swatch— a colour or gradient — orswatchImage),buttons,dimensions(number fields). when/unlesson a step, an option or a field:{ step: [values] }, only steps above.- Texts are a string (the default language) or
{ "en": "…", "uk": "…" }. - Pictures are media library keys, not ids.
The full reference — every key, the rules and the problem codes — is the MCP resource
configurators://schema, and the specification docs/architecture/WEBX_UI_MODULE_CONFIGURATOR.md.
The price
- For each visible choice step, in order:
fixedas it is,perM2× the area (the formula of the chosen option of the one step that has formulas). Every line is rounded to a cent. percentof each visible step — of the sum of step 1, never of another percent.- The discount, when it is in force on the day: a percent of what 1 and 2 give.
- The total, rounded to
pricing.round, half away from zero, never below 0.
The engine is pure PHP (WebxUi\Configurator\Engine\Engine); Pricing\Quoter is what the rest
calls. The npm package has a JS copy of the same rules for the instant price on the page; the
cases in resources/fixtures/pricing/ hold both to the same numbers.
MCP
configurators_list, _get, _create, _update, _publish, _unpublish, _discard,
_versions, _version_restore, _delete (every write takes dry_run), configurators_quote and
configurators_validate (read-only). An agent builds a configurator end to end:
- read
configurators://schema(andconfigurators://catalogfor what exists); media_upload_from_urlfor the pictures, thenmedia_get_filefor their keys (path);configurators_validatethe document;configurators_createwithdry_run: true, then without;configurators_quoteon a few combinations (actionsreplay a visitor aftervaluesare resolved);configurators_publish;- the block
configuratoron a page (blocks_edit_content):configuratoris the key,titleempty for the configurator's own,preset{ step: value, field: number }or null.
On the site
php artisan webx:blocks:offered --install --module=configurators
The block configurator takes a configurator, a heading (- is none) and where it starts —
values and sizes picked from the configurator's published steps. In a template:
<x-webx-configurator key="shower" />. The server prints every step, the price of the start and
its breakdown, «from N» on the cards, the picture, a discount in force and the messengers of the
site's contacts; the widget (dist/configurator.js, built from resources/js and the npm engine
with npx vite build in this folder) recounts as the visitor chooses.
«Get a quote» opens the configurator's inbox form in a dialog. The radios and the sizes belong to
that form (form=), so they go with the contacts with and without JavaScript; the server prices
them again — a price in the request is never read — and writes the configuration into the
submission. The base look is resources/theme/configurator.css; its classes are listed in
AGENTS.md.
With the catalogue
With webx-ui/module-catalog installed, both ways and from this package's side only:
- a product names a configurator and where it starts (
configurator.key,configurator.presetin its form and incatalog_products_update); its page shows «Calculate in the configurator», which leads to the configurator's page (a setting of the configurator) with?configurator=<key>&preset[<step>]=<value>— read asinitial, never trusted; - an option names a product by its article number (
"product": "SKU-1"); while it is chosen, the configurator shows up to four pictures of the product's gallery and a link — nothing for a product the site does not show.
Without the catalogue an option keeps its product and shows nothing.
The demo
php artisan webx:demo --module=configurators makes a shower enclosure configurator with no
company in it and example prices: eight constructions, nine glasses, frosting, six kinds of
hardware, two picture rules. Its words are in English, Russian and Ukrainian; its pictures are
neutral drawings put into the media library. With the inbox it gets the request form
configurator-request; with the catalogue's demo products, its first constructions show them «in
real life» and one of them opens the configurator.
License
MIT