BYOB bundle not appearing in cart after adding (theme compatibility fix)
Update (October 2026): The Custom JavaScript field in the Simple Bundles app block and app embed is deprecated. Add scripts with a Custom Liquid block or section in your theme instead, as shown in the steps below. Some screenshots may still show the old Custom JavaScript field while we update them.
If you already have code in the Custom JavaScript field, it keeps working for now, but we recommend moving it to a Custom Liquid block. Copy your code somewhere safe first: once you clear the field and save, the field disappears from your settings.
The problem
When a customer adds a BYOB bundle to their cart, the cart icon or drawer doesn't update. The bundle was added successfully, but the theme's cart UI doesn't show it until the customer refreshes the page.
This happens because the BYOB widget uses its own add-to-cart flow. Some themes only update their cart UI when products are added through the theme's native product form. The BYOB widget dispatches a simple-bundles-byob:add-to-cart event after adding, but not all themes listen for it.
Who this affects
Stores using:
- Themes with custom cart drawers or AJAX cart functionality
- Third-party cart drawer apps
- Heavily customized Dawn-based themes
If your theme uses Shopify's standard cart page (no drawer, no AJAX updates), you won't see this issue.
The fix
Add a small script that listens for the BYOB add-to-cart event and triggers a cart refresh. This works for most themes.
Add the script with a Custom Liquid section
- Go to Online Store > Themes
- Click Customize on your live theme
- Use the template selector at the top to open the Default product template
- Click Add section and choose Custom Liquid
- Paste the code below into the Custom Liquid field
- Rename the section to SB: BYOB cart refresh (optional, helps you find it later)
- Save
The code
Copy this entire block:
<script>
(function() {
// Set to true if you want the cart drawer to open after adding a BYOB bundle
const openCartDrawerAfterByobAdd = true;
// How often to check if the cart updated (milliseconds)
const cartUpdateInterval = 500;
// How many times to check before giving up
const cartUpdateAttempts = 10;
async function getCart() {
const root = window.Shopify?.routes?.root || '/';
const response = await fetch(root + 'cart.js', {
credentials: 'same-origin',
headers: { Accept: 'application/json' }
});
if (!response.ok) throw new Error('Cart request failed: ' + response.status);
return response.json();
}
async function waitForCartUpdate(previousCart) {
for (let attempt = 0; attempt < cartUpdateAttempts; attempt++) {
await new Promise(r => setTimeout(r, cartUpdateInterval));
const currentCart = await getCart();
if (currentCart.item_count !== previousCart.item_count ||
currentCart.total_price !== previousCart.total_price ||
currentCart.token !== previousCart.token) {
return currentCart;
}
}
return null;
}
document.addEventListener('simple-bundles-byob:add-to-cart', async function() {
try {
const previousCart = await getCart();
const updatedCart = await waitForCartUpdate(previousCart);
if (!updatedCart) return;
// Tell the theme the cart changed
document.dispatchEvent(new CustomEvent('cart:update', {
bubbles: true,
detail: { resource: updatedCart, data: { source: 'simple-bundles-byob', sections: {} } }
}));
// Open cart drawer if enabled
if (openCartDrawerAfterByobAdd) {
var drawer = document.querySelector('cart-drawer-component');
if (drawer && drawer.open) drawer.open();
}
} catch (e) {
console.error('Unable to update cart after BYOB add:', e);
}
});
})();
</script>
Configuration options
You can adjust two settings at the top of the script:
| Setting | Default | What it does |
|---|---|---|
openCartDrawerAfterByobAdd |
true |
Open the cart drawer after adding. Set to false if you just want the cart icon to update. |
cartUpdateInterval |
500 |
Milliseconds between cart checks. Lower = faster response, higher = less network requests. |
Theme-specific notes
Most themes respond to the cart:update event. If your cart drawer still doesn't open, your theme may use a different method. Common alternatives:
- Dawn and Dawn-based themes: The code above should work as-is
- Debut: Add
$(document).trigger('cart.requestComplete');after the cart:update dispatch - Custom cart drawer apps: Check the app's documentation for their cart refresh event
If the cart drawer selector cart-drawer-component doesn't match your theme, inspect your cart drawer element and update the selector on the line that calls .open().
Testing
- Open a BYOB product page
- Add items to fill the required slots
- Click "Add bundle to cart"
- The cart icon should update and (if enabled) the cart drawer should open
If the cart still doesn't update, check your browser console for errors and contact support with the error message.