Skip to content

Product Details initialization

The Product Details initializer configures how product information is displayed and managed, including images, descriptions, pricing, and options. Use initialization to customize product data models and enhance product presentation.

Version: 1.3.5

Configuration options

The following table describes the configuration options available for the Product Details initializer:

ParameterTypeReq?Description
langDefinitionsLangDefinitionsNoLanguage definitions for internationalization (i18n). Override dictionary keys for localization or branding.
modelsRecord<string, any>NoCustom data models for type transformations. Extend or modify default models with custom fields and transformers.
scopestringNoDefines the store view scope for product data retrieval. Used in multi-store setups to fetch store-specific product information.
defaultLocalestringNoSets the default locale for product content when no specific locale is detected.
globalLocalestringNoOverrides locale detection and forces all product content to use this specific locale regardless of user settings.
skustringNoPre-loads a specific product SKU on initialization. Useful for server-side rendering or direct product page access.
acdlbooleanNoConfiguration for Adobe Client Data Layer (ACDL) integration to track product view events and user interactions for analytics.
anchorsstring[]NoControls hash navigation behavior for product page sections (e.g., #reviews, #specifications). Enables deep linking to specific content areas.
persistURLParamsbooleanNoDetermines which URL query parameters should persist when navigating between product variants. Useful for tracking campaigns or referral sources.
preselectFirstOptionbooleanNoWhen `true`, automatically selects the first available option for each configurable attribute. Streamlines selection for products with default variants.
optionsUIDsstring[]NoPre-selects specific product options by their unique identifiers. Useful for direct links to configured product variants (e.g., specific size/color combinations).

Basic initialization

Initialize the drop-in with default settings:

import { initializers } from '@dropins/tools/initializer.js';
import { initialize } from '@dropins/storefront-pdp';
await initializers.mountImmediately(initialize, {});

Language definitions

Override dictionary keys for localization or branding. The langDefinitions object maps locale keys to custom strings that override the drop-in’s default text.

import { initializers } from '@dropins/tools/initializer.js';
import { initialize } from '@dropins/storefront-pdp';
const customStrings = {
'AddToCart': 'Add to Bag',
'Checkout': 'Complete Purchase',
'Price': 'Cost',
};
const langDefinitions = {
default: customStrings,
};
await initializers.mountImmediately(initialize, { langDefinitions });

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

The following models can be customized through the models configuration option:

The following example shows how to customize the CustomModel model for the Product Details drop-in:

import { initializers } from '@dropins/tools/initializer.js';
import { initialize } from '@dropins/storefront-pdp';
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-specific configuration

The Product Details drop-in provides additional configuration options beyond the standard langDefinitions and models. These options customize drop-in-specific behaviors and features.

import { initializers } from '@dropins/tools/initializer.js';
import { initialize } from '@dropins/storefront-pdp';
await initializers.mountImmediately(initialize, {
// Drop-in-specific configuration
scope: 'value',
defaultLocale: 'value',
globalLocale: 'value',
sku: 'value',
acdl: true,
anchors: 'value',
persistURLParams: true,
preselectFirstOption: true,
optionsUIDs: 'value',
});

Configuration types

The following TypeScript definitions show the structure of each configuration object:

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;
};
};

models

Maps model names to transformer functions. Each transformer receives data from GraphQL and returns a modified or extended version. Use the Model<T> type from @dropins/tools to create type-safe transformers.

models?: {
[modelName: string]: Model<any>;
};