🚀 UI Package Integration Guide
The injectConfigurator function injects the OV25 configurator UI into existing DOM elements on your page. It finds elements by CSS selectors and either replaces or appends the configurator components.
📦 Installation
Install the package using npm:
💡 Note: Always use
@latestto ensure you have the most recent version with all the latest features and bug fixes.
📦 Usage
✅ Required Fields
| Field | Type | Description |
|---|---|---|
apiKey | StringOrFunction | OV25 API key |
productLink | StringOrFunction | Product ID or path (e.g. '217', 'snap2/4', 'range/126') |
selectors | SelectorsConfig | DOM targets for gallery, price, name, variants, swatches, configureButton |
callbacks | CallbacksConfig | addToBasket, buyNow, buySwatches (required); onChange (optional) |
Full Config Type
Minimal Example
🎯 Selectors
Each selector can be a string (CSS selector) or an object:
| Selector | Purpose | Required | Notes |
|---|---|---|---|
gallery | Main 3D/image container | Standard products | Ignored for Snap2 (gallery is inside modal) |
price | Price display | When not hiding pricing | Omit when flags.hidePricing: true |
name | Product name | Recommended | |
variants | Variant controls | Products with variants | Omit for products without variants |
swatches | Swatch selector | Products with swatches | Omit when no swatches |
configureButton | Button that opens configurator | Snap2 | Required for Snap2; optional for standard |
Replace vs Append
replace: true– Replaces the target element's content with the configurator UIreplace: falseor omitted – Appends the UI inside the target element
Examples from Tests
Standard product with full selectors:
Snap2 with configure button:
Configure button only:
No variants – omit variants:
No pricing – omit price, set flags.hidePricing: true:
🎠 Carousel
Controls thumbnail display below the main image.
| Value | Description |
|---|---|
'none' | No carousel thumbnails |
'stacked' | Thumbnails stacked vertically |
'carousel' | Thumbnails in horizontal carousel |
Defaults: desktop: 'stacked', mobile inherits from desktop.
Examples
No carousel:
Stacked with max images:
Horizontal carousel:
Standard:
🎛️ Configurator
Controls how the configurator panel is shown and how variants are displayed.
Display Mode
| Desktop | Mobile | Description |
|---|---|---|
'inline' | 'inline' | Variants shown inline on the page |
'sheet' | 'drawer' | Full-screen sheet (desktop), bottom drawer (mobile) |
'sheet' | 'inline' | Sheet on desktop, inline on mobile |
Defaults: desktop: 'sheet', mobile: 'drawer' (when desktop is sheet) or 'inline' (when desktop is inline).
Trigger Style
'single-button'– One "Configure" button'split-buttons'– Separate Add to basket / Buy now
Default: 'single-button'
Variant Display Mode
| Value | Description |
|---|---|
'tree' | Hierarchical tree |
'list' | Flat list |
'tabs' | Tabbed groups |
'accordion' | Collapsible sections (desktop only; mobile falls back to tree) |
'wizard' | Step-by-step wizard |
Defaults: desktop: 'tree', mobile: 'list'
useSimpleVariantsSelector
When true, shows a single "Configure" button that opens the variant panel. Useful when you don't want inline variant controls.
Examples
Inline + wizard:
Sheet + tabs:
Inline + accordion:
Configure button only with simple selector:
📞 Callbacks
- addToBasket – Add configured product to basket. When invoked by the UI, always receives
OnChangePayload;skusandpriceinside may benulluntil those messages have been received. - buyNow – Checkout immediately. When invoked by the UI, always receives
OnChangePayload;skusandpriceinside may benulluntil those messages have been received. - buySwatches – Purchase selected swatches. Receives
Swatch[]andSwatchRulesData. - onChange – Optional. Called when price or SKU changes. Receives
OnChangePayload;skusandpriceare eachnulluntil that message type has been received at least once.
📋 Payload Types (skus and price)
The callbacks addToBasket, buyNow, and onChange receive an OnChangePayload. This object contains two keys: skus and price. Each key is null until the configurator iframe has sent that message type at least once. After the first CURRENT_SKU message, skus is populated; after the first CURRENT_PRICE message, price is populated.
Always null-check before using:
OnChangePayload
| Key | Type | When populated |
|---|---|---|
skus | OnChangeSkuPayload | null | After first CURRENT_SKU message from configurator |
price | OnChangePricePayload | null | After first CURRENT_PRICE message from configurator |
OnChangeSkuPayload (skus)
When payload.skus is not null, it contains the current SKU data for the configured product:
| Field | Type | Description |
|---|---|---|
skuString | string | Full concatenated SKU string for the current configuration (e.g. 'RED-001-M-001'). Use this for cart/checkout. |
skuMap | OptionSkuMap | undefined | Per-option SKU values. Keys are option names; values are selected SKU codes. |
OnChangePricePayload (price)
When payload.price is not null, it contains the current price data:
| Field | Type | Description |
|---|---|---|
totalPrice | number | Final price after discount, in minor units (e.g. pence, cents). |
subtotal | number | Subtotal before discount, in minor units. |
formattedPrice | string | Display string for final price (e.g. '£1,200.00'). |
formattedSubtotal | string | Display string for subtotal (e.g. '£1,500.00'). |
discount.amount | number | Discount amount in minor units. |
discount.formattedAmount | string | Display string for discount (e.g. '£300.00'). |
discount.percentage | number | Discount percentage (e.g. 20 for 20%). |
Swatch and SwatchRulesData (buySwatches)
Example with onChange
⚙️ Optional Fields
configurationUuid
Snap2 saved configuration. Restores a previously saved config.
images
Override product images (e.g. for galleries with custom image sets).
uniqueId
Disambiguates when multiple configurators share global containers (e.g. mobile drawer, toaster).
branding
cssString – Custom CSS injected into configurator components:
flags
| Flag | Type | Description |
|---|---|---|
hidePricing | boolean | Hide price display |
hideAr | boolean | Hide AR features |
deferThreeD | boolean | Defer 3D loading |
showOptional | boolean | Show optional options |
forceMobile | boolean | Force mobile layout (e.g. for device frame testing) |
autoOpen | boolean | Auto-open configurator on load (non-inline only). Default false. |
🏷️ Product Types (productLink)
| Pattern | Example |
|---|---|
| Single product | '217', '58', '607' |
| Snap2 | 'snap2/4', 'snap2/126' |
| Range | 'range/126', 'range/85' |
🔄 Multiple Configurators
Pass an array of configs. Each config must use distinct selectors (e.g. #gallery-1, #gallery-2). For standard configs, gallery and variants selectors must be unique across configs.
⚠️ Snap2 with
replace: trueon configure buttons: When multiple Snap2 configs usereplace: true, only one configurator instance is active at a time. Clicking a different configure button switches to that product's configurator.
Snap2, configure buttons only:
4 products with gallery, price, name:
Inline variant controls per product – use configurator.displayMode: { desktop: 'inline', mobile: 'inline' }.
Ranges with variants – use productLink: 'range/126' with variants selector.
🌐 Global APIs
When the configurator is injected, these functions are exposed on window:
| Function | Description |
|---|---|
window.ov25OpenConfigurator(optionName?) | Open configurator; optionally focus an option group (e.g. 'wood finishes') |
window.ov25CloseConfigurator() | Close configurator |
window.ov25OpenSwatchBook() | Open swatch book |
window.ov25CloseSwatchBook() | Close swatch book |
Example:
🕰️ Legacy Format
A flat config format is supported for backward compatibility. Use addToBasketFunction, buyNowFunction, buySwatchesFunction (or addSwatchesToCartFunction as alias), onChangeFunction, and flat selector/carousel/configurator fields instead of callbacks, selectors, carousel, configurator. The grouped format above is preferred.
Built with ❤️ by the Orbital Vision team