Biscuits Bundles components communicate through standard DOM CustomEvents and expose runtime configuration on the global window.BiscuitsBundle object. This page lists every event you can listen for and the most useful global hooks.
Each component fires a one-time :ready event when it finishes initialising. All bubble and carry no detail payload.
Event | Fired by |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Event | Fired on | When |
| the | After every sub-component is ready and the bundle has finished its first render. This is the safe entry point for custom code. |
Event |
| When |
|
| A product/variant is selected or deselected. |
|
| A quantity control value changes and passes validation. |
|
| A step's totals/validation change after a selection or quantity change. The primary event to listen to for reacting to selections. Does not fire for custom-field changes. |
| none | A custom field's value changes. Read current values from the field elements (it's a signal, not a snapshot). |
|
| The accordion auto-advances to the next incomplete step. |
|
| The bundle was added successfully, before any theme cart drawer/refresh runs. |
|
| The add-to-cart request failed (non-2xx response or network error). Does not fire on client-side validation errors. |
window.BiscuitsBundle globalUseful properties and helpers available at runtime:
Property | Description |
| Formats a cents integer into a localised money string. |
| The shop's money format strings. |
| All app language strings, keyed by translation key. |
|
|
| Pixel offsets for auto-scroll (default |
| Set |
| Control post-add-to-cart cart drawer/redirect behaviour. |
Run code after the bundle is ready
const form = document.querySelector('biscuits-bundle-form');
form.addEventListener('BiscuitsBundle:allReady', () => {
// All components are initialised — safe to read form.formTotalPrice, etc.
});💡 Tip: Make sure you don't put this event listener inside a "DOMContentLoaded" as our ready events will trigger before this.
React to selection changes
const form = document.querySelector('biscuits-bundle-form');
form.addEventListener('BiscuitsBundle:allReady', () => {
form.querySelectorAll('biscuits-bundle-step').forEach((step) => {
step.addEventListener('biscuits--step-update', (event) => {
// event.target is the <biscuits-bundle-step>
// event.detail.totalPrice, event.detail.valid, etc.
});
});
});React to a successful add-to-cart
const addToCart = document.querySelector('biscuits-bundle-add-to-cart');
addToCart.addEventListener('biscuits--add-to-cart-success', (event) => {
const cartResponse = event.detail.data; // Shopify cart/add.js response
});Read the current total
const form = document.querySelector('biscuits-bundle-form');
form.addEventListener('BiscuitsBundle:allReady', () => {
form.querySelectorAll('biscuits-bundle-step').forEach((step) => {
step.addEventListener('biscuits--step-update', () => {
const totalCents = form.formTotalPrice;
const formatted = window.BiscuitsBundle.formatMoney(totalCents, window.BiscuitsBundle.moneyFormat);
// formatted holds the current total (after discounts), in the shop's money format
});
});
});When using the Custom JS field in the Biscuits Bundles app block, your custom javascript code is placed at the very bottom of our Shopify theme block code. This ensures that you can use event listeners on our custom events and interact with fully loaded DOM elements.
<!-- our Biscuits Bundles code -->
<script>
/* Your custom javascript will output here */
</script>
<script src="biscuits-section-bundle-production.min.js" defer></script>Some of the other values you could access on the form are:
formCompareAtPrice
formDiscountValue
formSavingsAmount
formSavingsPercentage
formTotalPrice
Always thoroughly test your custom JS to ensure if behaves as expected across all supported browsers and devices.
Stuck or got questions?
Use the chat widget below, or reach out to us at [email protected]
Happy coding, and thanks for teaming up with Biscuits Bundles!