closed#3926
Closed
bashu-shopify wants to merge 3 commits into
Closed
Conversation
Storefront Renderer injects the Standard Actions bundle (window.Shopify.actions) into the page. The default updateCart handler already understands Dawn's cart refresh contract — it walks getSectionsToRender() on Dawn's cart custom elements, fetches /cart.js?sections= to morph sections in place, and publishes 'cart-update' through Dawn's pubsub. This override adds the one Dawn-specific bit the defaults can't cover: openCart, which opens the <cart-drawer> dialog. Falls back to /cart when the drawer isn't rendered (cart_type = page, or already on the cart page). Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Configure both openCart and updateCart explicitly in Dawn instead of relying on the bundle's built-in Dawn detection. Two reasons: 1. Forks that change Dawn's cart contract (custom elements, pubsub event shape, getSectionsToRender) silently break the built-in path. Putting the wiring in-theme keeps it visible and forkable. 2. Once most Dawn-based themes ship explicit integration, the built-in Dawn fallback in the actions bundle can be dropped. The updateCart handler mirrors the bundle's built-in behavior: collect sections advertised by mounted cart custom elements (skipping those Dawn's own pubsub subscribers already refresh), fetch /cart.js?sections=, morph the DOM in place, then publish cart-update so subscribers (quick-add-bulk, price-per-item, recipient-form, …) react. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- refreshDawnCartUI always fetches /cart.js so the published cart-update payload includes cartData even when no Dawn cart custom elements are mounted. Prevents quick-add-bulk.js from throwing on event.cartData.items on pages where cart_type = page or the header lacks <cart-drawer>. - updateCart configuration sets eventTarget: () => document explicitly. The SSE bundle types mark eventTarget as required; runtime tolerates omission today but that's a latent contract violation. - openCart delegates to defaultHandler() instead of duplicating the bundle's /cart redirect fallback. - updateCart handler drops unused ...args (defaultHandler is pre-bound with payload/options/cartId). - DAWN_CART_TAGS and DAWN_PUBSUB_REFRESHED_SECTIONS get inline maintenance comments pointing to the Dawn source-of-truth for the next person who touches cart.js#onCartUpdate. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.