Skip to content

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 raw number you can use for arithmetic
  • getResolve* — 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 | undefined

Returns 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


getPriceFormatter

getPriceFormatter: () => Intl.NumberFormat | undefined

Returns 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


Option-level

calculateOptionPriceWithQuantities

calculateOptionPriceWithQuantities: (args: {
option: TOption;
elementQuantities: TQuantities[string];
}) => number

Computes 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

NameTypeDescription
args.optionTOptionThe option whose price to calculate
args.elementQuantitiesTQuantities[string]Quantity map for the parent element ({ [optionId]: number })

Related


getResolveOptionPrice

getResolveOptionPrice: () => (args: {
option: TOption;
includedText?: string;
element: TElement;
}) => string

Returns 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)

NameTypeDescription
args.optionTOptionThe option to format
args.includedTextstring (optional)Text shown when the option is “included” (price is 0 or marked included)
args.elementTElementParent element (used to determine inclusion rules)

Related


getResolveOptionPriceWithQuantities

getResolveOptionPriceWithQuantities: () => (args: {
option: TOption;
includedText?: string;
element: TElement;
elementQuantities: TQuantities[string];
}) => string

Returns 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)

NameTypeDescription
args.optionTOptionThe option to format
args.includedTextstring (optional)Text shown when included
args.elementTElementParent element
args.elementQuantitiesTQuantities[string]Quantity map for the element

Element-level

calculateElementPrice

calculateElementPrice: (args: {
element: TElement;
values: TValues;
quantities: TQuantities;
}) => number

Calculates 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

NameTypeDescription
args.elementTElementThe element to price
args.valuesTValuesCurrent selected values
args.quantitiesTQuantitiesCurrent option quantities

Related


getResolveElementPrice

getResolveElementPrice: () => (args: {
element: TElement;
values: TValues;
quantities: TQuantities;
includedText?: string;
}) => string

Returns a formatter function that resolves the total price of a form element to a localised string.

Parameters (formatter)

NameTypeDescription
args.elementTElementThe element to format
args.valuesTValuesCurrent selected values
args.quantitiesTQuantitiesCurrent option quantities
args.includedTextstring (optional)Text shown when the total is 0 or “included”

Group-level

calculateGroupPrice

calculateGroupPrice: (args: {
group: TGroup;
values: TValues;
quantities: TQuantities;
}) => number

Calculates the total price for all elements inside a group.

Sums calculateElementPrice across every element in the group.

Parameters

NameTypeDescription
args.groupTGroupThe group to price
args.valuesTValuesCurrent selected values
args.quantitiesTQuantitiesCurrent option quantities

Related


getResolveGroupPrice

getResolveGroupPrice: () => (args: {
group: TGroup;
values: TValues;
quantities: TQuantities;
includedText?: string;
}) => string

Returns a formatter function that resolves the total price of a group to a localised string.

Parameters (formatter)

NameTypeDescription
args.groupTGroupThe group to format
args.valuesTValuesCurrent selected values
args.quantitiesTQuantitiesCurrent option quantities
args.includedTextstring (optional)Text shown when total is 0 or included

Step-level

calculateStepPrice

calculateStepPrice: (args: {
step: TStep | undefined;
values: TValues;
quantities: TQuantities;
}) => number

Calculates 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

NameTypeDescription
args.stepTStep | undefinedThe step to price
args.valuesTValuesCurrent selected values
args.quantitiesTQuantitiesCurrent option quantities

Related


getResolveStepPrice

getResolveStepPrice: () => (args: {
step: TStep | undefined;
values: TValues;
quantities: TQuantities;
includedText?: string;
}) => string

Returns 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;
}) => number

Calculates the combined price across multiple steps.

Sums calculateStepPrice for each entry in steps.

Parameters

NameTypeDescription
args.steps(TStep | undefined)[]The steps to price (typically formSubstore.fromConfigs[id].steps)
args.valuesTValuesCurrent selected values
args.quantitiesTQuantitiesCurrent option quantities

Related


getResolveStepsPrice

getResolveStepsPrice: () => (args: {
steps: (TStep | undefined)[];
values: TValues;
quantities: TQuantities;
includedText?: string;
}) => string

Returns a formatter function that resolves the combined price of multiple steps to a localised string.


Config-level

calculateConfigPrice

calculateConfigPrice: (args: {
configId: number;
multiplyConfigQuantity: boolean;
}) => number

Calculates 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

NameTypeDescription
args.configIdnumberTarget configuration ID
args.multiplyConfigQuantitybooleanWhether to multiply by the config’s quantity

Related


getResolvedConfigPrice

getResolvedConfigPrice: (args: {
configId: number;
multiplyConfigQuantity: boolean;
includedText?: string;
}) => string

Returns the formatted price string for a configuration.

Parameters

NameTypeDescription
args.configIdnumberTarget configuration ID
args.multiplyConfigQuantitybooleanWhether to multiply by the config’s quantity
args.includedTextstring (optional)Text shown when the total is 0 or included

Related


calculateConfigVat

calculateConfigVat: (args: {
configId: number;
multiplyConfigQuantity: boolean;
}) => number

Calculates the total VAT amount for a configuration, optionally multiplied by its quantity.

Uses the VAT rate defined in formSubstore.fromConfigs[configId].form.vat.

Parameters

NameTypeDescription
args.configIdnumberTarget configuration ID
args.multiplyConfigQuantitybooleanWhether to multiply by the config’s quantity

Related


getResolvedConfigVat

getResolvedConfigVat: (args: {
configId: number;
multiplyConfigQuantity: boolean;
}) => string

Returns the formatted VAT string for a configuration.

Parameters

NameTypeDescription
args.configIdnumberTarget configuration ID
args.multiplyConfigQuantitybooleanWhether to multiply by the config’s quantity

Related