Context (Commerce Engine)
Context (Commerce Engine)
|
|
Note
This component was introduced in version |
The Context controller exposes methods for managing the global context in a commerce interface.
Methods
setCountry
Sets the country.
Parameters
-
country:
stringThe new country.
setCurrency
Sets the currency.
Parameters
-
currency:
CurrencyCodeISO4217The new currency.
setLanguage
Sets the language.
Parameters
-
language:
stringThe new language.
subscribe
Adds a callback that’s invoked on state change.
Parameters
-
listener:
() => voidA callback that’s invoked on state change.
Returns Unsubscribe: A function to remove the listener.
Attributes
state
A scoped and simplified part of the headless state that is relevant to the Context controller.
Properties
-
country:
string -
currency:
CurrencyCodeISO4217 -
language:
string -
view:
View
Initialize
buildContext
Creates a Context controller instance.
Parameters
-
engine:
CommerceEngineThe headless commerce engine.
-
props:
ContextPropsThe configurable
Contextproperties.
Returns Context
ContextProps
The configurable Context properties.
Properties
-
options?:
ContextOptionsThe initial options that should be applied to this
Contextcontroller.
ContextOptions
The initial options that should be applied to this Context controller.
Properties
-
country:
string -
currency:
CurrencyCodeISO4217 -
language:
string -
view:
View
Related types
Unsubscribe
Call signatures
-
(): void;
View
Properties
-
url:
string