Wishlist initialization
The Wishlist initializer configures wishlist functionality including saving items, sharing lists, and managing multiple wishlists. Use initialization to customize wishlist behavior and data models.
Configuration options
Section titled “Configuration options”The following table describes the configuration options available for the Wishlist initializer:
| Parameter | Type | Req? | Description |
|---|---|---|---|
langDefinitions | LangDefinitions | No | Provides language definitions for internationalization (i18n). Overrides dictionary keys for localization or branding. |
isGuestWishlistEnabled | boolean | No | Allows guest users to create and manage wishlists without authentication when set to true. Stores guest wishlists in browser storage. |
storeCode | string | No | Scopes wishlist data (cookies and browser storage) per store. Shares wishlist data across all stores when omitted or set to default. |
pageSize | number | No | Number of items per page for wishlist containers. When omitted, the drop-in uses its built-in default. |
guestWishlistTtl | Record<string, number> | No | Per-list expiry, in days, for named guest lists. Keys are list keys (such as save-for-later). Each value is the number of days that list persists in browser storage. See Guest list expiry. |
Multistore support
Section titled “Multistore support”In multistore storefronts, pass a storeCode so that the drop-in isolates wishlist data per store view. The Commerce Boilerplate reads the value from the Store header defined in config.json:
const headers = getHeaders('wishlist');
await initializers.mountImmediately(initialize, { isGuestWishlistEnabled: true, storeCode: headers.Store,});When storeCode is set to a value other than default, the drop-in appends __<storeCode> to its browser storage keys and to the wishlist ID cookie. This isolates guest wishlist data and cached authenticated data per store view, and does not change the authoritative wishlist scope in Adobe Commerce. When storeCode is omitted or set to default, the drop-in keeps the original unscoped keys for backward compatibility.
Default configuration
Section titled “Default configuration”The initializer runs with these defaults when no configuration is provided:
import { initializers } from '@dropins/tools/initializer.js';import { initialize } from '@dropins/storefront-wishlist';
// All configuration options are optionalawait initializers.mountImmediately(initialize, { langDefinitions: {}, // Uses built-in English strings models: {}, // Uses default data models // Drop-in-specific defaults: // isGuestWishlistEnabled: undefined // See configuration options below});Language definitions
Section titled “Language definitions”Override dictionary keys for localization or branding. The langDefinitions object maps locale keys to custom strings that override default text for the drop-in.
import { initializers } from '@dropins/tools/initializer.js';import { initialize } from '@dropins/storefront-wishlist';
const customStrings = { 'AddToCart': 'Add to Bag', 'Checkout': 'Complete Purchase', 'Price': 'Cost',};
const langDefinitions = { default: customStrings,};
await initializers.mountImmediately(initialize, { langDefinitions });Customizing data models
Section titled “Customizing data models”Extend or transform data models by providing custom transformer functions. Use the models option to add custom fields or modify existing data structures returned from the backend.
Available models
Section titled “Available models”The following models can be customized through the models configuration option:
The following example shows the general models configuration pattern used across Commerce drop-ins (for reference if you extend the initializer):
import { initializers } from '@dropins/tools/initializer.js';import { initialize } from '@dropins/storefront-wishlist';
const models = { CustomModel: { transformer: (data) => ({ // Add custom fields from backend data customField: data?.custom_field, promotionBadge: data?.promotion?.label, // Transform existing fields displayPrice: data?.price?.value ? `${data.price.value}` : 'N/A', }), },};
await initializers.mountImmediately(initialize, { models });Drop-in configuration
Section titled “Drop-in configuration”The Wishlist initializer configures wishlist functionality including saving items, sharing lists, and managing multiple wishlists. Use initialization to customize wishlist behavior and data models.
import { initializers } from '@dropins/tools/initializer.js';import { initialize } from '@dropins/storefront-wishlist';
await initializers.mountImmediately(initialize, { langDefinitions: {}, isGuestWishlistEnabled: true,});Guest list expiry
Section titled “Guest list expiry”When you render an additional guest list beyond the default wishlist (for example, a “Save for Later” list), you can set how long that list persists in the guest’s browser. Use guestWishlistTtl to map each list key to a number of days:
import { initializers } from '@dropins/tools/initializer.js';import { initialize } from '@dropins/storefront-wishlist';
await initializers.mountImmediately(initialize, { isGuestWishlistEnabled: true, guestWishlistTtl: { 'save-for-later': 14, // The guest "Save for Later" list expires after 14 days },});Configuration types
Section titled “Configuration types”The following TypeScript definitions show the structure of each configuration object:
langDefinitions
Section titled “langDefinitions”Maps locale identifiers to dictionaries of key-value pairs. The default locale is used as the fallback when no specific locale matches. Each dictionary key corresponds to a text string used in the drop-in UI.
langDefinitions?: { [locale: string]: { [key: string]: string; };};