Skip to content

Bump Spree SDK to 0.14 - #73

Merged
damianlegawiec merged 2 commits into
mainfrom
fix/spree-sdk-0-14
Mar 19, 2026
Merged

Bump Spree SDK to 0.14#73
damianlegawiec merged 2 commits into
mainfrom
fix/spree-sdk-0-14

Conversation

@damianlegawiec

@damianlegawiec damianlegawiec commented Mar 19, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Chores
    • Bumped Spree packages to latest patch versions.
  • UI
    • Address fields and postal code now follow updated naming (reflected across checkout and address forms).
    • Credit card displays now show brand and last4.
    • Variant options and product filters now use updated labels for clearer option text.
    • Coupon/discount lines and totals updated to reflect current discount fields.
  • Analytics
    • Tracking adjusted to align with updated cart/line-item discount data.

@coderabbitai

coderabbitai Bot commented Mar 19, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 626d10c5-ea1a-41e6-bfde-77afe80a3e56

📥 Commits

Reviewing files that changed from the base of the PR and between 2f48f81 and e161263.

📒 Files selected for processing (2)
  • src/components/checkout/Summary.tsx
  • src/lib/analytics/gtm.ts
✅ Files skipped from review due to trivial changes (1)
  • src/components/checkout/Summary.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/lib/analytics/gtm.ts

Walkthrough

The PR updates the storefront to align with Spree SDK 0.14.x: it renames address fields (firstname/lastname/zipcode → first_name/last_name/postal_code), address containers (ship_address/bill_address → shipping_address/billing_address), card fields (cc_type/last_digits → brand/last4), discount fields (promo_total/promotions → discount_total/discounts), and product option fields (presentation → label) across UI, data, and analytics code.

Changes

Cohort / File(s) Summary
Dependency Versions
package.json
Bumped @spree/next ^0.13.0 → ^0.14.1 and @spree/sdk ^0.13.0 → ^0.14.2.
Address Utilities & Data Layer
src/lib/utils/address.ts, src/lib/data/checkout.ts
Renamed address form schema fields to snake_case (first_name, last_name, postal_code); updated updateOrderAddresses payload to shipping_address/billing_address and shipping_address_id/billing_address_id; added optional use_shipping; removed addressesMatch.
Checkout Components (address & form)
src/components/checkout/AddressEditModal.tsx, src/components/checkout/AddressFormFields.tsx, src/components/checkout/AddressSection.tsx, src/components/checkout/AddressSelector.tsx, src/app/.../checkout/[id]/page.tsx
Mapped form IDs, values, and onChange keys to snake_case names; changed auto-save and payloads to shipping_address/shipping_address_id; updated required field checks to last_name/postal_code.
Payment / Billing Flow & Cards
src/components/checkout/PaymentSection.tsx, src/components/account/CreditCardList.tsx, src/components/account/OrderDetail.tsx
Replaced card fields (cc_type/last_digits) with (brand/last4) for icons/labels; changed onUpdateBillingAddress prop to accept optional { billing_address?, use_shipping? }; rely on shipping_eq_billing_address instead of removed addressesMatch.
Cart, Drawer, Summary & Analytics (discounts/quantities)
src/app/.../cart/page.tsx, src/components/cart/CartDrawer.tsx, src/components/checkout/Summary.tsx, src/lib/analytics/gtm.ts
Switched promo fields to discount fields (promo_total/display_promo_totaldiscount_total/display_discount_total), promotionsdiscounts, and item_counttotal_quantity; analytics line-item discount computation adjusted to use per-unit discount and quantity clamping; coupon extraction now reads from order.discounts.
Order-placed & Order Detail Rendering
src/app/.../order-placed/[id]/page.tsx, src/components/account/OrderDetail.tsx
Switched order address sources to shipping_address/billing_address; use .postal_code instead of .zipcode; replaced promo_total usage with discount_total; show customer_note instead of special_instructions.
Address Management Display
src/components/addresses/AddressManagement.tsx
Address postal/ZIP display uses address.postal_code instead of address.zipcode.
Coupon UI
src/components/checkout/CouponCode.tsx
Derive applied coupon-like entries from cart.discounts rather than cart.promotions, keeping same filter and render logic.
Product Options & Filters
src/components/products/VariantPicker.tsx, src/components/products/filters/*
Use label for option type/value and color resolution instead of presentation across variant picker and filter UIs.
Misc (small updates)
src/components/checkout/Summary.tsx, src/components/cart/CartDrawer.tsx
Minor conditional checks and display field swaps to the new discount and quantity fields (see cart/summary cohorts above).

Estimated Code Review Effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 I hop through fields both old and new,

first_name, last_name—nice and true.
Postal codes now dance in place,
Cards show brand and last4's grace.
A little rabbit cheers this code-refresh brew.

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 4.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Bump Spree SDK to 0.14' is vague and incomplete, failing to convey the scope of extensive API field renames and structural changes across the codebase beyond just dependency version updates. Consider a more descriptive title that captures the breaking API changes, such as 'Align API field names with Spree SDK 0.14 (ship/bill addresses, promo/discount fields, card details)' or 'Update to Spree SDK 0.14 with field naming standardization'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/spree-sdk-0-14
📝 Coding Plan
  • Generate coding plan for human review comments

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/lib/utils/address.ts (1)

62-75: ⚠️ Potential issue | 🔴 Critical

Fix camelCase key mismatch in address conversion.

The AddressParams type from @spree/sdk v0.14.2 expects camelCase keys (firstname, lastname, zipcode), not snake_case. This function will send ignored keys and break address persistence for names and postal codes.

Required changes
 export function formDataToAddress(data: AddressFormData): AddressParams {
   return {
-    first_name: data.first_name,
-    last_name: data.last_name,
+    firstname: data.first_name,
+    lastname: data.last_name,
     address1: data.address1,
     address2: data.address2 || undefined,
     city: data.city,
-    postal_code: data.postal_code,
+    zipcode: data.postal_code,
     phone: data.phone || undefined,
     company: data.company || undefined,
     country_iso: data.country_iso,
     state_abbr: data.state_abbr || undefined,
     state_name: data.state_name || undefined,
   };
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/lib/utils/address.ts` around lines 62 - 75, The formDataToAddress
function returns snake_case keys that don't match the AddressParams shape from
`@spree/sdk` v0.14.2; update the returned object in formDataToAddress to use the
expected AddressParams property names (e.g., map first_name -> firstname,
last_name -> lastname, postal_code -> zipcode, state_abbr -> stateAbbr,
state_name -> stateName, address2/phone/company keep as optional but using the
SDK's key casing) so the address payload matches the SDK contract.
🧹 Nitpick comments (1)
src/lib/utils/address.ts (1)

17-29: Prefer satisfies for emptyAddress.

This keeps the literal checked against AddressFormData without widening it through an annotation.

♻️ Possible cleanup
-export const emptyAddress: AddressFormData = {
+export const emptyAddress = {
   first_name: "",
   last_name: "",
   address1: "",
   address2: "",
   city: "",
   postal_code: "",
   phone: "",
   company: "",
   country_iso: "",
   state_abbr: "",
   state_name: "",
-};
+} satisfies AddressFormData;
As per coding guidelines, "Use strict TypeScript type checking. Always define explicit return types for functions, use 'satisfies' for type checking object literals, and avoid 'any' (use 'unknown' instead)."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/lib/utils/address.ts` around lines 17 - 29, Replace the type annotation
on the emptyAddress object with TypeScript's "satisfies" operator so the literal
is type-checked against AddressFormData without widening; locate the exported
constant emptyAddress and change its declaration to use "satisfies
AddressFormData" (retaining the same property values) so the compiler enforces
the shape while preserving literal types.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/checkout/Summary.tsx`:
- Around line 68-73: The conditional uses parseFloat(cart.discount_total) which
yields NaN when discount_total is undefined, causing the Discount row to render;
update the check in the Summary component to guard for a missing value first,
e.g. use Number(cart.discount_total ?? 0) !== 0 or (cart.discount_total != null
&& parseFloat(cart.discount_total) !== 0) so the row only renders when
cart.discount_total is present and non-zero; keep rendering of
cart.display_discount_total unchanged.

In `@src/lib/analytics/gtm.ts`:
- Line 221: The code currently assigns coupon with order.discounts?.[0]?.code
which picks index 0 even when that discount has no code; change it to search for
the first discount object that has a non-empty code (e.g., use
Array.prototype.find on order.discounts) and set coupon to that discount.code
(ensuring null/undefined safety), updating the variable named coupon in
src/lib/analytics/gtm.ts so coupon reflects the first discount with a code
rather than always index 0.
- Around line 110-112: The code sets item.discount from the line-level
discount_total which overstates discounts when quantity > 1; change the
assignment in the GTM mapping so that if discountTotal < 0 you divide the
absolute line discount by the lineItem.quantity (use
safeParseFloat(lineItem.quantity) or parseInt) to compute a per-unit discount,
and assign that value to item.discount (preserving existing use of
safeParseFloat for discountTotal and referencing lineItem.discount_total,
lineItem.quantity, and item.discount to locate the change).

---

Outside diff comments:
In `@src/lib/utils/address.ts`:
- Around line 62-75: The formDataToAddress function returns snake_case keys that
don't match the AddressParams shape from `@spree/sdk` v0.14.2; update the returned
object in formDataToAddress to use the expected AddressParams property names
(e.g., map first_name -> firstname, last_name -> lastname, postal_code ->
zipcode, state_abbr -> stateAbbr, state_name -> stateName,
address2/phone/company keep as optional but using the SDK's key casing) so the
address payload matches the SDK contract.

---

Nitpick comments:
In `@src/lib/utils/address.ts`:
- Around line 17-29: Replace the type annotation on the emptyAddress object with
TypeScript's "satisfies" operator so the literal is type-checked against
AddressFormData without widening; locate the exported constant emptyAddress and
change its declaration to use "satisfies AddressFormData" (retaining the same
property values) so the compiler enforces the shape while preserving literal
types.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4ca4bf4e-3102-4fae-ab20-a3dac8568e4a

📥 Commits

Reviewing files that changed from the base of the PR and between 6b763b1 and 2f48f81.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (23)
  • package.json
  • src/app/[country]/[locale]/(checkout)/checkout/[id]/page.tsx
  • src/app/[country]/[locale]/(checkout)/order-placed/[id]/page.tsx
  • src/app/[country]/[locale]/(storefront)/cart/page.tsx
  • src/components/account/CreditCardList.tsx
  • src/components/account/OrderDetail.tsx
  • src/components/addresses/AddressManagement.tsx
  • src/components/cart/CartDrawer.tsx
  • src/components/checkout/AddressEditModal.tsx
  • src/components/checkout/AddressFormFields.tsx
  • src/components/checkout/AddressSection.tsx
  • src/components/checkout/AddressSelector.tsx
  • src/components/checkout/CouponCode.tsx
  • src/components/checkout/PaymentSection.tsx
  • src/components/checkout/Summary.tsx
  • src/components/products/VariantPicker.tsx
  • src/components/products/filters/FilterChips.tsx
  • src/components/products/filters/MobileFilterDrawer.tsx
  • src/components/products/filters/OptionDropdownContent.tsx
  • src/components/products/filters/ProductFilters.tsx
  • src/lib/analytics/gtm.ts
  • src/lib/data/checkout.ts
  • src/lib/utils/address.ts

Comment thread src/components/checkout/Summary.tsx Outdated
Comment thread src/lib/analytics/gtm.ts Outdated
Comment thread src/lib/analytics/gtm.ts Outdated
@damianlegawiec
damianlegawiec merged commit f68cb9a into main Mar 19, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant