@@ -79,7 +79,7 @@ function collectCartSections() {
7979// that isn't already refreshed by Dawn's own pubsub subscribers, then
8080// publish 'cart-update' so the subscribers run.
8181//
82- // We always fetch /cart.js (with sections= when we have any) so that
82+ // We always fetch /cart.js so that
8383// `cartData` is defined for subscribers. quick-add-bulk.js reads
8484// `event.cartData.items` unconditionally — publishing without cartData
8585// makes it throw.
@@ -90,14 +90,17 @@ async function refreshDawnCartUI() {
9090 : '' ;
9191 // `routes` is a Dawn global, but don't assume it's defined.
9292 const cartUrl = ( typeof routes !== 'undefined' && routes ?. cart_url ) || '/cart' ;
93- const url = `${ cartUrl } .js${ sectionsQuery } ` ;
94- const cartData = await fetch ( url , { headers : { Accept : 'application/json' } } )
93+ const cartData = await fetch ( `${ cartUrl } .js` , { headers : { Accept : 'application/json' } } )
9594 . then ( ( r ) => ( r . ok ? r . json ( ) : null ) )
9695 . catch ( ( ) => null ) ;
9796
98- if ( cartData ?. sections ) {
97+ if ( sections . size ) {
98+ const sectionsData = await fetch ( `${ cartUrl } ${ sectionsQuery } ` , { headers : { Accept : 'application/json' } } )
99+ . then ( ( r ) => ( r . ok ? r . json ( ) : null ) )
100+ . catch ( ( ) => null ) ;
101+
99102 for ( const [ id , { mount, extractSelector } ] of sections ) {
100- const html = cartData . sections [ id ] ;
103+ const html = sectionsData ?. [ id ] ;
101104 if ( ! html ) continue ;
102105 const source = new DOMParser ( )
103106 . parseFromString ( html , 'text/html' )
@@ -107,7 +110,7 @@ async function refreshDawnCartUI() {
107110 }
108111
109112 // Hand off to Dawn's existing subscribers. cartData is the full
110- // Cart Ajax payload (items, item_count, token, …) plus sections ;
113+ // Cart Ajax payload (items, item_count, token, …);
111114 // quick-add-bulk.js and price-per-item.js read it directly.
112115 publish ( PUB_SUB_EVENTS . cartUpdate , {
113116 source : 'external-refresh' ,
0 commit comments