<dkl-price> is event-driven. It has no direct reference to the
volume picker — instead it listens for the picker’s tier-change
event and the theme’s variant-change events, and updates the price accordingly.
Listens for
Emitted by the volume picker. Matched by product id — a
selected tier shows the discounted price, a
null tier reverts to base. Coupling is by
event name and product id only, with no import between the two components.Honours the event’s updatesPrice flag: if the picker’s “Update price when a tier is
selected” setting is off, <dkl-price> ignores the tier for pricing (the event still
fires for other listeners).Emits
<dkl-price> emits a price-change event whenever its displayed price updates, plus
mount / unmount lifecycle events. All bubble, so you can listen on document.
widgetId and variantId. widgetId is the app block’s id — it’s null on a web component,
variantId is the current variant and
updates as the shopper switches variants (not just the variant at page load).Price change
Fired whenever the displayed price changes — when a volume tier is selected or deselected, or
the variant changes. Not fired on initial mount (the server-rendered price is already in
the DOM), and deduped — a recompute that lands on the same price (e.g. switching to an
equally-priced variant) doesn’t fire. The detail carries
resource with the previous and new
price, mirroring the tier event’s previousTier / currentTier:Lifecycle
The mount / unmount events fire as the instance’s behaviour attaches and tears down — handy for wiring up (and cleaning up) custom integrations per instance. Both carry aDklWidgetEventDetail resource.
Fired once the controller has attached its behaviour to the (already server-rendered)
element.
resource: { widgetType, widgetId, productId?, variantId? } — productId and
variantId are included when known.Fired when the instance tears down — e.g. the element is removed, or the theme editor
re-renders the section. Same
resource shape. Use it to detach any listeners or observers
you set up on mount.Next steps
Web Components
Listener and
MutationObserver examples for reacting to changes.Volume Picker
The component that emits the tier-change event.