Faqs
JavaScript events for developers
2 min read
1. Page loaded
document.addEventListener('page:loaded', function() {
// Page has loaded and theme assets are ready
})2. Product successfully added to the Ajax cart
document.addEventListener('product-ajax:added', function(evt) {
console.log(evt.detail.product);
});3. Product could not be added to the Ajax cart
document.addEventListener('product-ajax:error', function(evt) {
console.log(evt.detail.errorMessage);
});4. Cart updated
document.addEventListener('cart:updated', function(evt) {
console.log(evt.detail.cart);
});5. Quick view modal has been opened
document.addEventListener('quick-view:open', function(evt) {
console.log(evt.detail.productUrl);
});6. Quick view modal has been loaded
document.addEventListener('quick-view:loaded', function(evt) {
console.log(evt.detail.productUrl);
});7. Variant selection changed
document.addEventListener('variant:changed', function(evt) {
console.log(evt.detail.variant);
});8. Collection page is refreshed
document.addEventListener('collection:rerendered', function() {
console.log('collection refreshed');
});9. Trigger cart drawer to refresh
document.dispatchEvent(new CustomEvent('cart:refresh', {
bubbles: true, detail: { open: true }
}));10. Product recommendations loaded
document.addEventListener('recommendations:loaded', (event) => {
console.log(event, 'related products loaded complete');
// Run your custom callback or re-init logic here
});Last updated