Home > widget-integration > CombinedProductListingsController

CombinedProductListingsController class

Signature:

export declare class CombinedProductListingsController 

Constructors

Constructor

Modifiers

Description

(constructor)(swatchService, combinedProductListingsService)

Constructs a new instance of the CombinedProductListingsController class

Properties

Property

Modifiers

Type

Description

childProductVariantsCache

protected

Map<string, PreOrderVariant[]>

childVariantPreorderCache

protected

Map<string, PreOrderData>

COMBINED_LISTING_CHILD_PID_KEY

static

string

COMBINED_LISTING_CHILD_VID_KEY

static

string

combinedListingDataCache

protected

Map<string, CombinedListingState | null>

combinedListingDataPromiseCache

protected

Map<string, Promise<void>>

combinedListingState

CombinedListingState | null

swatchService

ProductSwatchService

triggerUpdate

(modal: HTMLElement) => void

Methods

Method

Modifiers

Description

autoSelectFirstCombinedChildVariant(modal)

bindChildSwatchOptionEvents(option, modal, triggerUpdate)

bindCombinedChildSwatches(container, triggerUpdate)

buildChildVariantFromSelections(getSelectedVariant)

buildCombinedStateFromAPIResponse(response)

buildCombinedStateFromProductData(productData)

castToPreOrderVariant(variant)

clearChildSelection()

Clears child variant and selected child variant from state. Used when no parent variant is selected or when resetting.

clearCombinedListingCache()

Clear all caches for combined listing data.

clearCombinedListingChildSession()

Removes combined listing child product/variant IDs from sessionStorage.

Called when the quick-view modal is closed to prevent stale child IDs from being picked up by subsequent tracking events on normal (non-combined) products.

ensureCombinedListingState(productId, productData)

Ensure combined listing state is loaded and cached. Checks configuration and attempts to fetch if enabled or product appears to be combined listing.

ensureSelectedChildVariantInVariants(childVariants)

protected

findParentVariantByChildVariantId(childVariantId, getParentVariantById, getCurrentSelectedParentVariant)

findVariantInCombinedListing(variantId, product, getVariantById)

getChildProductVariants(childProductId, requiredVariantId)

protected

getChildSwatches(modal)

getCombinedListingVariantForCart(getSelectedVariant)

Return the variant for cart actions: child, parent fallback, or null when pending.

getCombinedResolvedVariant(fallbackVariant)

getFirstVisibleParentOption(modal)

getProductHandleFromUrl()

getProductIdFromPage()

getSelectedCombinedChildVariant()

getSelectedParentOptionValues(modal)

getSelectedParentOptionValuesFromPage()

getVariantIdFromProductForm()

handleChildSwatchSelect(modal, option, triggerUpdate)

handleCombinedParentSwatchSelect(modal, option, variants, triggerUpdate)

Handles parent swatch selection for combined listing products. Matches variant by merged_options, resolves child, auto-selects first child variant. Equivalent to handleSwatchSelect but for combined-listing parent swatches.

handleParentSwatchChanged(modal, getSelectedVariant)

Handles parent swatch change: resolves child product, clears previous child selection, auto-selects first available child variant, and persists to session.

hasRealChildOptions(child)

True when the child has real user-selectable options (not just a single "Default Title").

hydrateChildVariantFromCache(variant)

protected

hydrateCombinedChildVariantPreorder(childProductId, childVariantId, onPreorderHydrated)

protected

initCombinedListingState(modal, preOrderVariants, getSelectedVariant, handleSwatchSelect)

Resolve child product for the selected parent variant and initialise state on modal open.

initCombinedListingThumbnailNavigation(modal, fallbackImages, hooks)

Initializes thumbnail navigation for combined listing slider. Resolves images from current child variant state with fallback.

initCombinedSwatchSelection(modal, triggerUpdate)

initializePreOrderIntegration(params)

initStateFromProductData(productData)

Initializes combined listing state from product data if the feature is enabled. Sets combinedListingState to the built state or null.

injectThumbnailNavigationButtons(modal)

Inject prev/next thumbnail nav button wrappers when absent from the modal.

logPreOrderResolve(stage, payload)

protected

matchChildVariantByValues(child, selectedValues)

matchParentVariantByValues(selectedValues)

primeCombinedListingState(productId)

protected

Fetch and cache combined listing data with deduplication. If a fetch is already in progress, waits for it instead of fetching again.

resolveCombinedChildVariant(parentVariant, preferredChildVariantId, hydrateFromCache, findVariant)

resolveCombinedChildVariantForPreOrder(parentVariant, preferredChildVariantId, findVariant, onPreorderHydrated)

resolveCurrentVariantIdForChange(getVariantIdFromUrl, getSelectedVariant, getFirstAvailableVariant)

resolveFirstChildVariant(child)

resolveInitialVariantForPreOrder(params)

resolveParentVariantFromPageOptions(getParentVariantById)

resolvePreOrderIntegrationOnVariantChange(params)

resolvePreOrderVariantOnChange(params)

resolveProductDataForRender(product)

resolveVariantFromParentProduct(currentVariantId, product, fetchProductData, getVariantById, getCurrentSelectedParentVariant)

saveCombinedListingChildToSession()

Persists the active combined listing child product and variant IDs to sessionStorage.

This enables the analytics module (analytic/index.js) to attribute add-to-cart, buy-now, and pre-order tracking events to the correct child product when the user interacts inside the quick-view modal.

Called after combined listing state changes: modal open, parent swatch change, and child swatch change. Clears keys when no child is active.

showCombinedUnavailableState(modal, unavailableLabel)

Shows the "unavailable" state for combined listing when no parent variant is matched. Disables ATC, hides buy-now and pre-order blocks.

syncCombinedListingSlider(modal, images, sliderRef, onThumbClick)

Sync slider slides and thumbnail strip to the given images. Only called when a child product is active.

syncCombinedSliderIfChildActive(modal, fallbackImages, sliderRef, onThumbClick)

Resolves images for the combined slider and syncs the slider DOM if a child variant is active. Returns the resolved images array for the caller to use for UI updates.

syncSelectedChildVariantPreorderFromVariants(childVariants)

protected

updateChildSwatchesDisabledState(modal)

updateCombinedChildSoldOutLabels(modal, child)

Mark child swatch labels sold-out when no available variant covers that option value.

updateCombinedListingUI(modal, selectedVariant, hooks)

Update price and ATC button after swatch changes (parent-only / child pending / child resolved).

updateCombinedQuickViewUI(modal, selectedVariant, fallbackImages, sliderRef, hooks)

Full UI update orchestration for combined listing products in quick-view. Handles: no-variant state (clear child, disable swatches, reset slider), variant-selected state (price/ATC, labels, detail link, slider sync).

wait(delayMs)

protected