your function updateCartDrawer(cart) is empty. How can i update the cart drawer?
Topic summary
Users report that the cart drawer in Shopify’s Dawn theme fails to update automatically when items are added. The drawer shows as empty even after adding products, and customers cannot view their cart without manually refreshing the page.
Root Cause Identified:
One user discovered the issue stems from missing DOM elements that the fetchQuantityRules() function expects. Specifically, removing the quantity rules label (class=“quantity__rules-cart…”) from main-product.liquid breaks the cart update functionality.
Proposed Solutions:
- AJAX approach: Use
fetch('/cart.js')to retrieve cart data asynchronously and update the drawer without full page refresh - DOM element fix: Either restore the missing quantity rules element or add a safety check (
if (!this.querySelector('.quantity__rules-cart')) return;) inproduct-info.js(around line 61) - jQuery reload: Intercept AJAX cart additions and reload specific elements using
$('#cart-drawer').load(location.href + " #cart-drawer") - Custom form handling: Implement custom AJAX submission that manually updates cart count and drawer state
Status: Multiple users confirmed solutions work, though implementation varies by Dawn version. The issue typically affects stores with customized themes or page builders that modify default Dawn structure.