@runwell/shopify-toolkit 0.24.2 → 0.24.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -155,7 +155,10 @@
155
155
  display: flex;
156
156
  flex-direction: column;
157
157
  gap: 10px;
158
- margin-bottom: 1.2rem;
158
+ margin: 0 0 1.2rem 0;
159
+ padding: 0;
160
+ border: 0;
161
+ min-inline-size: 0;
159
162
  }
160
163
 
161
164
  .runwell-bundle-quantity-builder__option {
@@ -175,8 +178,7 @@
175
178
  }
176
179
 
177
180
  .runwell-bundle-quantity-builder__option--selected {
178
- border-color: #2A2622;
179
- box-shadow: 0 0 0 1px #2A2622;
181
+ border-color: #3F5B4C;
180
182
  }
181
183
 
182
184
  .runwell-bundle-quantity-builder__option--popular {
@@ -151,27 +151,63 @@
151
151
  items.push({ id: parseInt(giftVariantId, 10), quantity: 1 });
152
152
  }
153
153
 
154
+ // Dawn's cart-drawer needs the cart-drawer + cart-icon-bubble
155
+ // sections re-rendered before .open() will show the new items
156
+ // (it starts in is-empty state and renderContents() updates +
157
+ // opens in one call). We pass `sections` to /cart/add.js so the
158
+ // response includes the freshly rendered HTML for each.
159
+ const drawer = document.querySelector('cart-drawer');
160
+ const cartSections = drawer && typeof drawer.getSectionsToRender === 'function'
161
+ ? drawer.getSectionsToRender().map(function (s) { return s.section || s.id; }).filter(Boolean)
162
+ : ['cart-drawer', 'cart-icon-bubble'];
163
+
154
164
  fetch('/cart/add.js', {
155
165
  method: 'POST',
166
+ credentials: 'same-origin',
156
167
  headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
157
- body: JSON.stringify({ items: items }),
168
+ body: JSON.stringify({ items: items, sections: cartSections, sections_url: window.location.pathname }),
158
169
  })
159
170
  .then(function (r) {
160
- if (!r.ok) throw new Error('add failed');
171
+ if (!r.ok) {
172
+ return r.text().then(function (text) {
173
+ throw new Error('cart/add ' + r.status + ': ' + text.slice(0, 200));
174
+ });
175
+ }
161
176
  return r.json();
162
177
  })
163
- .then(function () {
178
+ .then(function (json) {
164
179
  setAtcState(atc, 'added');
165
180
  document.dispatchEvent(new CustomEvent('cart:updated', { bubbles: true }));
166
- // Open Dawn cart drawer if present
167
- const drawer = document.querySelector('cart-drawer');
168
- if (drawer && typeof drawer.open === 'function') drawer.open();
169
- setTimeout(function () {
170
- setAtcState(atc, 'idle');
171
- }, 2000);
181
+
182
+ // Dawn pattern: renderContents(parsedState) updates each
183
+ // section's DOM from json.sections and opens the drawer.
184
+ if (drawer && typeof drawer.renderContents === 'function') {
185
+ drawer.renderContents(json);
186
+ setTimeout(function () { setAtcState(atc, 'idle'); }, 2000);
187
+ return;
188
+ }
189
+ // Fallback A: drawer exists but no renderContents (older
190
+ // theme). Open and hope the drawer fetches fresh state.
191
+ if (drawer && typeof drawer.open === 'function') {
192
+ drawer.open();
193
+ setTimeout(function () { setAtcState(atc, 'idle'); }, 2000);
194
+ return;
195
+ }
196
+ // Fallback B: send customer to /cart so they always land
197
+ // somewhere they can verify the items.
198
+ setTimeout(function () { window.location.href = '/cart'; }, 600);
172
199
  })
173
- .catch(function () {
200
+ .catch(function (err) {
201
+ console.error('[runwell-bundle] ATC failed:', err);
174
202
  setAtcState(atc, 'idle');
203
+ if (atc) {
204
+ const textEl = atc.querySelector('.runwell-bundle-quantity-builder__atc-text');
205
+ if (textEl) {
206
+ const original = textEl.textContent;
207
+ textEl.textContent = 'Could not add. Try again.';
208
+ setTimeout(function () { textEl.textContent = original; }, 3000);
209
+ }
210
+ }
175
211
  });
176
212
  });
177
213
  });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runwell-bundle-system",
3
- "version": "0.4.2",
3
+ "version": "0.4.4",
4
4
  "category": "catalog",
5
5
  "source": "runwell",
6
6
  "base": "bundle-system",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runwell/shopify-toolkit",
3
- "version": "0.24.2",
3
+ "version": "0.24.4",
4
4
  "description": "Reusable Shopify theme modules from Runwell. Replaces typically app-driven features (reviews, wishlist, urgency, FAQ, post-purchase upsell, exit popups, free-ship progress, sticky ATC, testimonials, badges, bundles) with native Liquid + JS + CSS that ship across multiple client themes via a config-driven sync CLI.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",