Commerce engine

This is for:

Developer

The engine for powering commerce experiences.

Initialize

buildCommerceEngine

Creates a commerce engine instance.

Parameters

Returns CommerceEngine

CommerceEngineOptions

The commerce engine options.

Properties

  • configuration: CommerceEngineConfiguration

    The commerce engine configuration options.

  • loggerOptions?: LoggerOptions

    The logger options.

  • middlewares?: Middleware<{}, State>[]

    List of additional middlewares. A middleware is a higher-order function that composes a dispatch function to return a new dispatch function. It is useful for logging actions, performing side effects like routing, or turning an asynchronous API call into a series of synchronous actions.

  • navigatorContextProvider?: NavigatorContextProvider

    An optional function returning navigation context. (referer, location, UserAgent)

  • preloadedState?: State

    The initial headless state. You may optionally specify it to hydrate the state from the server in universal apps, or to restore a previously serialized user session.

CommerceEngineConfiguration

The commerce engine configuration options.

Properties

LoggerOptions

The logger options.

Properties

  • level?: LevelWithSilent

    By default, is set to warn.

  • logFormatter?: (object: {}) => {}

    Changes the shape of the log object. This function will be called every time one of the log methods (such as .info) is called. All arguments passed to the log method, except the message, will be pass to this function. By default it does not change the shape of the log object.

Middleware<{}, State>[]

List of additional middlewares. A middleware is a higher-order function that composes a dispatch function to return a new dispatch function. It is useful for logging actions, performing side effects like routing, or turning an asynchronous API call into a series of synchronous actions.

Properties

  • (call): (api: MiddlewareAPI<D, S>): (next: (action: unknown) => unknown) => (action: unknown) => unknown;

ContextOptions

The commerce context options.

Properties

  • country: string

  • currency: CurrencyCodeISO4217

  • language: string

  • view: View

CartInitialState

The initial cart state to restore.

Properties

View

Properties

  • url: string

CartItemWithMetadata[]

Properties

  • name: string

    The name of the cart item.

  • price: number

    The price of the cart item.

  • productId: string

    The unique identifier of the product.

  • quantity: number

    The quantity of the product in the cart.