numberFormatterSubstore
Provides all number and price formatting utilities for the SDK. All formatters are built from the currently selected language and country (localizationSubstore). Methods return undefined when the locale has not yet been resolved — guard against undefined before rendering.
The substore offers two levels of API:
calculate*— returns a rawnumberyou can use for arithmeticgetResolve*— returns a formatter function that converts a number to a localised string
Table of contents
Formatters
Option-level
Element-level
Group-level
Step-level
Steps (plural)-level
Config-level
Formatters
getNumberFormatter
getNumberFormatter: () => Intl.NumberFormat | undefinedReturns an Intl.NumberFormat instance for the selected language, or undefined if no language is set.
Use this for generic number formatting (no currency symbol). Returns undefined when localizationSubstore.selectedLanguage is undefined.
Related
localizationSubstore.selectedLanguagegetPriceFormatter— currency-aware variant
getPriceFormatter
getPriceFormatter: () => Intl.NumberFormat | undefinedReturns a currency Intl.NumberFormat for the selected language and country, or undefined if not fully resolved.
Returns undefined when either localizationSubstore.selectedLanguage or localizationSubstore.selectedCountry is undefined.
Related
localizationSubstore.selectedLanguagelocalizationSubstore.selectedCountrygetNumberFormatter— non-currency variant
Option-level
calculateOptionPriceWithQuantities
calculateOptionPriceWithQuantities: (args: { option: TOption; elementQuantities: TQuantities[string];}) => numberComputes the total price of an option multiplied by its quantity.
Returns option.price * elementQuantities[optionId] (or just option.price if no quantity is set).
Parameters
| Name | Type | Description |
|---|---|---|
args.option | TOption | The option whose price to calculate |
args.elementQuantities | TQuantities[string] | Quantity map for the parent element ({ [optionId]: number }) |
Related
getResolveOptionPriceWithQuantities— formatted string variantvaluesSubstore.valuesConfigs— source of quantities
getResolveOptionPrice
getResolveOptionPrice: () => (args: { option: TOption; includedText?: string; element: TElement;}) => stringReturns a formatter function that resolves an option’s price to a localised string.
Call once to get the formatter, then call the formatter for each option. If the option is included in the base price, returns includedText (when provided) instead of the formatted price.
Parameters (formatter)
| Name | Type | Description |
|---|---|---|
args.option | TOption | The option to format |
args.includedText | string (optional) | Text shown when the option is “included” (price is 0 or marked included) |
args.element | TElement | Parent element (used to determine inclusion rules) |
Related
getResolveOptionPriceWithQuantities— quantity-aware variantgetPriceFormatter— theIntl.NumberFormatused internally
getResolveOptionPriceWithQuantities
getResolveOptionPriceWithQuantities: () => (args: { option: TOption; includedText?: string; element: TElement; elementQuantities: TQuantities[string];}) => stringReturns a formatter function that resolves an option’s price × quantity to a localised string.
Same as getResolveOptionPrice but multiplies by the option’s quantity before formatting.
Parameters (formatter)
| Name | Type | Description |
|---|---|---|
args.option | TOption | The option to format |
args.includedText | string (optional) | Text shown when included |
args.element | TElement | Parent element |
args.elementQuantities | TQuantities[string] | Quantity map for the element |
Element-level
calculateElementPrice
calculateElementPrice: (args: { element: TElement; values: TValues; quantities: TQuantities;}) => numberCalculates the total price for all selected options within a form element.
Iterates over the element’s options, filters to those present in values[elementId], and sums their prices (multiplied by quantity when applicable).
Parameters
| Name | Type | Description |
|---|---|---|
args.element | TElement | The element to price |
args.values | TValues | Current selected values |
args.quantities | TQuantities | Current option quantities |
Related
getResolveElementPrice— formatted string variantcalculateGroupPrice— calls this for each element in a group
getResolveElementPrice
getResolveElementPrice: () => (args: { element: TElement; values: TValues; quantities: TQuantities; includedText?: string;}) => stringReturns a formatter function that resolves the total price of a form element to a localised string.
Parameters (formatter)
| Name | Type | Description |
|---|---|---|
args.element | TElement | The element to format |
args.values | TValues | Current selected values |
args.quantities | TQuantities | Current option quantities |
args.includedText | string (optional) | Text shown when the total is 0 or “included” |
Group-level
calculateGroupPrice
calculateGroupPrice: (args: { group: TGroup; values: TValues; quantities: TQuantities;}) => numberCalculates the total price for all elements inside a group.
Sums calculateElementPrice across every element in the group.
Parameters
| Name | Type | Description |
|---|---|---|
args.group | TGroup | The group to price |
args.values | TValues | Current selected values |
args.quantities | TQuantities | Current option quantities |
Related
getResolveGroupPrice— formatted string variantcalculateStepPrice— calls this when the step is a group
getResolveGroupPrice
getResolveGroupPrice: () => (args: { group: TGroup; values: TValues; quantities: TQuantities; includedText?: string;}) => stringReturns a formatter function that resolves the total price of a group to a localised string.
Parameters (formatter)
| Name | Type | Description |
|---|---|---|
args.group | TGroup | The group to format |
args.values | TValues | Current selected values |
args.quantities | TQuantities | Current option quantities |
args.includedText | string (optional) | Text shown when total is 0 or included |
Step-level
calculateStepPrice
calculateStepPrice: (args: { step: TStep | undefined; values: TValues; quantities: TQuantities;}) => numberCalculates the total price for a single step (element or group).
Delegates to calculateElementPrice or calculateGroupPrice depending on the step type. Returns 0 when step is undefined.
Parameters
| Name | Type | Description |
|---|---|---|
args.step | TStep | undefined | The step to price |
args.values | TValues | Current selected values |
args.quantities | TQuantities | Current option quantities |
Related
getResolveStepPrice— formatted string variantcalculateStepsPrice— calls this for each step
getResolveStepPrice
getResolveStepPrice: () => (args: { step: TStep | undefined; values: TValues; quantities: TQuantities; includedText?: string;}) => stringReturns a formatter function that resolves the total price of a single step to a localised string.
Steps (plural)-level
calculateStepsPrice
calculateStepsPrice: (args: { steps: (TStep | undefined)[]; values: TValues; quantities: TQuantities;}) => numberCalculates the combined price across multiple steps.
Sums calculateStepPrice for each entry in steps.
Parameters
| Name | Type | Description |
|---|---|---|
args.steps | (TStep | undefined)[] | The steps to price (typically formSubstore.fromConfigs[id].steps) |
args.values | TValues | Current selected values |
args.quantities | TQuantities | Current option quantities |
Related
getResolveStepsPrice— formatted string variantformSubstore.fromConfigs— source ofsteps
getResolveStepsPrice
getResolveStepsPrice: () => (args: { steps: (TStep | undefined)[]; values: TValues; quantities: TQuantities; includedText?: string;}) => stringReturns a formatter function that resolves the combined price of multiple steps to a localised string.
Config-level
calculateConfigPrice
calculateConfigPrice: (args: { configId: number; multiplyConfigQuantity: boolean;}) => numberCalculates the total price for a configuration, optionally multiplied by its quantity.
Internally reads formSubstore.fromConfigs[configId].steps and valuesSubstore.valuesConfigs[configId], then calls calculateStepsPrice. If multiplyConfigQuantity is true, the result is multiplied by TConfig.configQuantity.
Parameters
| Name | Type | Description |
|---|---|---|
args.configId | number | Target configuration ID |
args.multiplyConfigQuantity | boolean | Whether to multiply by the config’s quantity |
Related
getResolvedConfigPrice— formatted string variantconfigsSubstore.configs— source ofconfigQuantityformSubstore.fromConfigs— source ofstepsvaluesSubstore.valuesConfigs— source of values and quantities
getResolvedConfigPrice
getResolvedConfigPrice: (args: { configId: number; multiplyConfigQuantity: boolean; includedText?: string;}) => stringReturns the formatted price string for a configuration.
Parameters
| Name | Type | Description |
|---|---|---|
args.configId | number | Target configuration ID |
args.multiplyConfigQuantity | boolean | Whether to multiply by the config’s quantity |
args.includedText | string (optional) | Text shown when the total is 0 or included |
Related
calculateConfigPrice— numeric variant
calculateConfigVat
calculateConfigVat: (args: { configId: number; multiplyConfigQuantity: boolean;}) => numberCalculates the total VAT amount for a configuration, optionally multiplied by its quantity.
Uses the VAT rate defined in formSubstore.fromConfigs[configId].form.vat.
Parameters
| Name | Type | Description |
|---|---|---|
args.configId | number | Target configuration ID |
args.multiplyConfigQuantity | boolean | Whether to multiply by the config’s quantity |
Related
getResolvedConfigVat— formatted string variantformSubstore.fromConfigs— source ofform.vat
getResolvedConfigVat
getResolvedConfigVat: (args: { configId: number; multiplyConfigQuantity: boolean;}) => stringReturns the formatted VAT string for a configuration.
Parameters
| Name | Type | Description |
|---|---|---|
args.configId | number | Target configuration ID |
args.multiplyConfigQuantity | boolean | Whether to multiply by the config’s quantity |
Related
calculateConfigVat— numeric variant