@runwell/shopify-toolkit 0.24.2 → 0.24.3

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.
@@ -175,8 +175,7 @@
175
175
  }
176
176
 
177
177
  .runwell-bundle-quantity-builder__option--selected {
178
- border-color: #2A2622;
179
- box-shadow: 0 0 0 1px #2A2622;
178
+ border-color: #3F5B4C;
180
179
  }
181
180
 
182
181
  .runwell-bundle-quantity-builder__option--popular {
@@ -153,25 +153,49 @@
153
153
 
154
154
  fetch('/cart/add.js', {
155
155
  method: 'POST',
156
+ credentials: 'same-origin',
156
157
  headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
157
158
  body: JSON.stringify({ items: items }),
158
159
  })
159
160
  .then(function (r) {
160
- if (!r.ok) throw new Error('add failed');
161
+ if (!r.ok) {
162
+ return r.text().then(function (text) {
163
+ throw new Error('cart/add ' + r.status + ': ' + text.slice(0, 200));
164
+ });
165
+ }
161
166
  return r.json();
162
167
  })
163
168
  .then(function () {
164
169
  setAtcState(atc, 'added');
165
170
  document.dispatchEvent(new CustomEvent('cart:updated', { bubbles: true }));
166
- // Open Dawn cart drawer if present
171
+ // Open the cart drawer when the theme exposes one. Fall back to
172
+ // /cart so the customer always lands somewhere they can verify
173
+ // the items landed.
167
174
  const drawer = document.querySelector('cart-drawer');
168
- if (drawer && typeof drawer.open === 'function') drawer.open();
169
- setTimeout(function () {
170
- setAtcState(atc, 'idle');
171
- }, 2000);
175
+ if (drawer && typeof drawer.open === 'function') {
176
+ drawer.open();
177
+ setTimeout(function () { setAtcState(atc, 'idle'); }, 2000);
178
+ } else if (drawer) {
179
+ drawer.classList.add('active');
180
+ document.body.classList.add('overflow-hidden');
181
+ setTimeout(function () { setAtcState(atc, 'idle'); }, 2000);
182
+ } else {
183
+ // No drawer wired up. Send the customer to /cart so they can
184
+ // see what was added rather than being stuck on the PDP.
185
+ setTimeout(function () { window.location.href = '/cart'; }, 600);
186
+ }
172
187
  })
173
- .catch(function () {
188
+ .catch(function (err) {
189
+ console.error('[runwell-bundle] ATC failed:', err);
174
190
  setAtcState(atc, 'idle');
191
+ if (atc) {
192
+ const textEl = atc.querySelector('.runwell-bundle-quantity-builder__atc-text');
193
+ if (textEl) {
194
+ const original = textEl.textContent;
195
+ textEl.textContent = 'Could not add. Try again.';
196
+ setTimeout(function () { textEl.textContent = original; }, 3000);
197
+ }
198
+ }
175
199
  });
176
200
  });
177
201
  });
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "runwell-bundle-system",
3
- "version": "0.4.2",
3
+ "version": "0.4.3",
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.3",
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",