Context (Commerce Engine)

This is for:

Developer

The Context controller exposes methods for managing the global context in a commerce interface.

Methods

setCountry

Sets the country.

Parameters

  • country: string

    The new country.

setCurrency

Sets the currency.

Parameters

  • currency: CurrencyCodeISO4217

    The new currency.

setLanguage

Sets the language.

Parameters

  • language: string

    The new language.

setView

Sets the view.

Parameters

  • view: View

    The new view.

subscribe

Adds a callback that’s invoked on state change.

Parameters

  • listener: () => void

    A 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: CommerceEngine

    The headless commerce engine.

  • props: ContextProps

    The configurable Context properties.

Returns Context

ContextProps

The configurable Context properties.

Properties

  • options?: ContextOptions

    The initial options that should be applied to this Context controller.

ContextOptions

The initial options that should be applied to this Context controller.

Properties

  • country: string

  • currency: CurrencyCodeISO4217

  • language: string

  • view: View

Unsubscribe

Call signatures

  • (): void;

View

Properties

  • url: string