If your theme or another script needs to react to Zepto Product Personalizer, listen for the two custom events it dispatches on window on the product page.

1. App initialized: pplrAppInitiated

Fired once the options have fully loaded on the product page. Use it for anything that must wait for the app.

Add this in your theme (for example theme.liquid, before the closing </head> or in Settings → Functionality → Custom JavaScript):

Settings → Functionality → Custom JavaScript

// Listen for the pplrAppInitiated custom event
window.addEventListener('pplrAppInitiated' , function(e) {
// check if pplr has loaded
})

2. Add to cart completed: pplrAddToCartCompleted

Fired after the personalized product and its selections have been added to the cart. To catch it, the shopper must stay on the product page: set Settings → Functionality → Add to cart → Action after a product is added to the cart to Stay on the product page and show a success message.

Settings → Functionality → Add to Cart

// Listen for the pplrAddToCartCompleted custom event
window.addEventListener('pplrAddToCartCompleted' , function(e) {
// check if the add to cart event has fired
})

More questions from support

Answers our team gave to merchants who read this article and still had a question. Each is a real case, with the store details removed.

Why does add to cart redirect to the cart page instead of opening the slide cart?

The app's add-to-cart action is set to redirect to cart instead of staying on the product page. Open the app's Settings → Functionality and change 'Add to Cart action' to 'Sync with theme (Beta)' to open your theme's slide cart. If syncing does not work, set it to 'Stay on the product page and display a success message', then use the pplrAddToCartCompleted custom event hook to trigger your slide cart's open function — see the custom event hooks article for the code snippet to add to your theme.

How do I add custom line item properties or close the popup with JavaScript?

The app only adds its own option properties to the cart. To add custom properties like a bundle ID, use the pplrAddToCartCompleted custom event hook in Settings → Functionality → Custom JavaScript to add code that modifies the cart line item. To close the On-Page / Popup personalization popup from your own JavaScript, call pplr_w_h() — for example, inside a setTimeout to close it after a delay. Rename how an option appears in the cart using the Custom Cart Label setting on each option.

Why does Add to Cart show 'added' but the cart stays empty and checkout doesn't open?

The app added the personalized product to the cart, but your theme's cart drawer is slow to update or you need a redirect to checkout. Add a script that listens to the app's pplrAddToCartCompleted event:

window.addEventListener('pplrAddToCartCompleted', function(e) { window.location.href = '/checkout'; });

Place it in your theme (e.g. theme.liquid or the product template) and test by personalizing and clicking Add to Cart — the shopper should go straight to checkout. If the cart drawer is just slow, wait a few seconds or refresh; if you need help with the script, chat with support with your product link.