@runwell/shopify-toolkit 0.24.1 → 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.1",
3
+ "version": "0.4.3",
4
4
  "category": "catalog",
5
5
  "source": "runwell",
6
6
  "base": "bundle-system",
@@ -206,8 +206,14 @@
206
206
  {%- capture tier_label -%}{{ t.qty }}x {{ product.title }}{%- endcapture -%}
207
207
  {%- endif -%}
208
208
 
209
- {%- assign discount_amount = tier_base_price | times: t.discount_pct | divided_by: 100 -%}
210
- {%- assign per_unit_price = tier_base_price | minus: discount_amount -%}
209
+ {%- comment -%}
210
+ Compute per_unit as base * (100 - pct) / 100 directly,
211
+ rather than base - (base * pct / 100). The direct form
212
+ avoids a half-cent rounding step that would otherwise
213
+ push, e.g., 50% off $49.99 from $24.99 up to $25.00.
214
+ {%- endcomment -%}
215
+ {%- assign keep_pct = 100 | minus: t.discount_pct -%}
216
+ {%- assign per_unit_price = tier_base_price | times: keep_pct | divided_by: 100 -%}
211
217
  {%- assign total_price = per_unit_price | times: t.qty -%}
212
218
  {%- assign full_price = tier_base_price | times: t.qty -%}
213
219
  {%- assign savings = full_price | minus: total_price -%}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@runwell/shopify-toolkit",
3
- "version": "0.24.1",
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",