Custom JavaScript events
Advanced
Last updated
Was this helpful?
Advanced
Last updated
Was this helpful?
We do not support code customizations. This guide offers a basic reference for developers. Always test code changes on unpublished theme copies. For assistance, we recommend reaching out to a .
For Stiletto, we've introduced custom events so developers can easily add their own functionality to the theme without needing to edit the theme's JavaScript files.
Use the custom-events.js
file included in the theme to add all your custom scripts in one place and effortlessly hook into Stiletto's JavaScript.
To enable custom events, you need to update the theme-globals.liquid
to import the custom-events.js
file that you'll be using for your scripts.
Once you've enabled custom events, you can start adding your custom scripts to the custom-events.js
file.
We've listed all exposed events within the custom-events.js
file so you can easily use and edit them there.
The following exposed events are available to use as a blueprint to get started:
This event fires when an item is added to the cart. The AJAX cart must be enabled for this event to be exposed. The product object is passed within the detail object.
This event fires when the cart has been updated. The AJAX cart must be enabled for the event to be exposed. The cart object is passed within the detail object.
This event fires when an error occurs with adding an item to the cart. This error typically occurs when a product is unavailable due to insufficient stock. The error message is passed within the detail object.
This event fires when the quick cart is opened. The AJAX cart must be enabled for the event to be exposed. The cart object is passed within the detail object.
This event fires when the quick cart is closed. The AJAX cart must be enabled for the event to be exposed.
This event fires when an a variant product is selected. A Variant selector block must be enabled on the product template or featured product section for the event to be exposed. The selected variant object is passed within the detail object.
This event fires when the product quantity is updated. A Quantity selector block must be enabled on the product template or featured product section for the event to be exposed. The quantity and selected variant objects are passed within the detail object.
This event fires when a quick view modal is opened. The Enable quick view setting must be enabled.
The following event can be used to refresh the quick cart and header cart count:
apps:product-added-to-cart
For example:
Related links
Please feel free to reach out with questions or introduce yourself by e-mailing us at