UNPKG

@dutchfurniturefulfilment/skik-client

Version:

Javascript package for integrating a SKIK configurator inside web projects.

79 lines (50 loc) 3.04 kB
## Listening for events ```typescript Client # on(eventChannel: string, handler: (payload: any) => void): EventSubscription ``` The `on` method allows you to listen for events from the Client, and in some cases from the configurator indirectly. The method accepts an [event channel](event-channels) string as its first argument, and a handler as its second. ## Requesting a configuration hash ```javascript Client # getConfigurationHash(): Promise<string> ``` `getConfigurationHash` returns a promise that will in time resolve to a hash representing the currently active configuration of the SKIK Configurator. A SKIK Configuration hash is a string representing a certain SKIK closet configuration. Such a hash can after retrieval be used to query for the relevant product data server-side (e.g. for adding items to cart) or simply to associate it as a 'favorite' of a certain user account. Hashes represent persisted, immutable SKIK closet configurations. ## Obtaining the IFrame element ```typescript Client # frameElement(): HTMLIFrameElement ``` Returns the IFrame element object in which the configurator is loaded. ## Toggling auto-resizing of the IFrame container ```typescript Client # enableAutoResize(): this Client # disableAutoResize(): this ``` The methods `enableAutoResize` and `disableAutoResize` allow you to toggle auto-sizing of the frame container element at runtime. ## Toggling display of the language switch ```typescript Client # showLocaleSwitch(): this Client # hideLocaleSwitch(): this ``` You might want to control the language setting programatically depending on your application's state. The methods `showLocaleSwitch` and `hideLocaleSwitch` allow you to toggle the display of the language switch at runtime. Initial configuration for this setting can be given at [`Client` construction](static#constructor-options). ## Setting the language of the configurator ```typescript Client # setLocale(locale: string): this ``` Sets the locale (language) of the configurator to given value, if the language is supported. Text contents of the configurator are updated in real-time. The given locale must be of type `string`: a language identifier in ISO 639-1 format. Currently supported languages: - `"nl"` (Dutch) - `"en"` (English) ## Getting an array of all product EAN codes ```typescript Client # getEANCodes(): Promise<string[]> ``` Returns a promise that resolves to a string-array containing all EAN codes for products used by the configurator. ## Setting the prices for products ```typescript Client # setProductPrices(prices: ProductPrices[]): Promise<boolean> ``` Stores given product prices, and then uses it to calculate / publish the total price of the current configuration. ## Setting custom article numbers for products ```typescript Client # setArticleNumbers(articleNumbers: ArticleNumber[]): Promise<boolean> ``` Stores given article numbers, and uses them to identify products within the product-manifest modal, and within PDF attachments sent along with sharing emails.