Skip to main content

Events reference

Events are callbacks the plugin fires when something happens. Register them on the pulpoar object:

pulpoar.onAddToCart((variants) => {
// ...
});

The Templates column shows which Theme Designer templates fire the event. "All" means every template.

Core events​

EventPayloadDescriptionTemplates
onReadyProject dataThe plugin is ready. The payload includes your catalog data.All
onErrorErrorSomething went wrong.All
onPathChange{ referer: string; path: string }The current screen changed.All
onTryNowClick{ fallback: string }The camera was started from the camera permission step. fallback is the path it opens.All
onGdprApprove{ approved: boolean }The GDPR checkbox was clicked.All
onGdprLinkClick{ url: string; text: string }A link in the GDPR text was clicked (when "convert links to events" is on).Basic, Advanced

Camera and photo events​

EventPayloadDescriptionTemplates
onUploadPhotoundefinedThe user uploaded a photo from the device.All
onModelSelect{ image: string; id: number }A model was selected.All
onTakePhotoundefinedA photo was taken.All
onUsePhotoundefinedUse Photo was clicked after taking a photo.All
onTakePhotoAgainundefinedTake Again was clicked after taking a photo.All
onCameraMirror{ active: boolean }The camera mirror setting changed.Basic, Simple, Advanced
onCameraSwitch{ facingMode: 'user' | 'environment' }The user switched between front and back camera.Basic, Simple

Catalog events​

EventPayloadDescriptionTemplates
onExperienceSelect{ type: 'look' | 'product' | 'live-camera' | 'take-photo' | 'upload-photo' | 'choose-model' }An experience was selected.All
onLookSelectLookA look was selected.All
onBrandSelectBrandA brand was selected.All
onCategorySelectCategoryA category was selected.All
onProductSelectProductA product was selected.All
onVariantSelectVariantA variant was selected.All
onAppliedVariantsChange{ variantIds: string[]; triggererVariantIds: string[] }The applied variants changed. This includes clearing them when the catalog is on.All
onTryOn{ variantIds: string[] }A product was actually applied and rendered. It never fires when makeup is cleared.All
onAddToCartVariant[]An Add to Cart button was clicked.All
onGoToProductVariant (includes product info)A variant link was clicked.All
onGoBackundefinedThe catalog's Go Back control was used.All
onContinue{ slug: string; variant: Variant }Continue was clicked on the try-on, with the shade on screen. Doesn't fire if no shade is selected.Popup

UI events​

EventPayloadDescriptionTemplates
onCurtainToggle{ active: boolean }The before/after curtain was toggled.All
onCurtainSlideStart{ posX: number }The user started dragging the before/after slider.All
onCurtainSlideEnd{ posX: number }The user stopped dragging the before/after slider.All
onOpacitySlideStart{ percentage: number }The user started dragging the opacity slider.Basic, Simple, Advanced
onOpacitySlideEnd{ percentage: number }The user stopped dragging the opacity slider.Basic, Simple, Advanced
onZoom{ type: 'in' | 'out'; value: number }The zoom level changed.Basic, Simple, Advanced

Common recipes​

Connect Add to Cart to your cart​

pulpoar.onAddToCart((variants) => {
variants.forEach((variant) => {
addToCart(variant.id, variant.name, variant.price);
});
});

Route to the product page in a mobile app​

In a WebView the plugin can't open links inside your app. Handle onGoToProduct and navigate yourself:

pulpoar.onGoToProduct((variant) => {
// variant includes product info
openProductScreen(variant);
});

Track what users try on​

pulpoar.onTryOn(({ variantIds }) => {
analytics.track('vto_try_on', { variantIds });
});