Skip to content

Bump to Spree SDK 0.12.0#68

Merged
damianlegawiec merged 2 commits intomainfrom
chore/spree-sdk-0-12
Mar 17, 2026
Merged

Bump to Spree SDK 0.12.0#68
damianlegawiec merged 2 commits intomainfrom
chore/spree-sdk-0-12

Conversation

@damianlegawiec
Copy link
Member

@damianlegawiec damianlegawiec commented Mar 17, 2026

Use new Spree 6-ready resources/naming

Summary by CodeRabbit

  • Updates
    • Replaced "shipping" wording with "delivery" and "fulfillments" across checkout, order pages, cart, and account views — UI labels, totals, and status badges updated.
    • Gift card status display updated (uses status values for label and color).
    • Product variant selection logic improved (default variant handling and variant filtering).
  • Chores
    • Core framework dependencies updated to newer versions.

Use new Spree 6-ready resources/naming
@coderabbitai
Copy link

coderabbitai bot commented Mar 17, 2026

Walkthrough

Dependency bumps to @spree/next and @spree/sdk (0.12.0) and a widespread terminology/schema refactor replacing "shipping"/"shipment" with "delivery"/"fulfillment" across data APIs, components, pages, tests, and analytics payloads.

Changes

Cohort / File(s) Summary
Dependencies
package.json
Bump @spree/next and @spree/sdk from ^0.11.0 → ^0.12.0.
Data API & Tests
src/lib/data/checkout.ts, src/lib/data/__tests__/checkout.test.ts
Renamed public APIs: getShipmentsgetFulfillments, selectShippingRateselectDeliveryRate; parameter names changed (shipmentId→fulfillmentId, shippingRateId→deliveryRateId); tests and mocks updated to fulfillments/delivery_rates.
Checkout UI Components
src/components/checkout/DeliveryMethodSection.tsx, src/components/checkout/Summary.tsx, src/components/checkout/index.ts
Renamed ShippingMethodSectionDeliveryMethodSection; props/callbacks renamed (onShippingRateSelect→onDeliveryRateSelect); references updated from shipments/shipping_ratesfulfillments/delivery_rates; index export adjusted.
Checkout Page Flow
src/app/.../(checkout)/checkout/[id]/page.tsx
Handler and imports updated to use delivery/fulfillment terminology and call selectDeliveryRate instead of selectShippingRate; mapping of selected rates updated to delivery_rates.
Order / Orders Pages
src/app/.../(storefront)/account/orders/[id]/page.tsx, src/app/.../(storefront)/account/orders/page.tsx
Renamed UI and types: ShipmentBlockFulfillmentBlock, ShipmentFulfillment; helper getShipmentStatusColorgetFulfillmentStatusColor; data fields switched (shipment_state→fulfillment_status, shipping_method→delivery_method, state→status); totals use display_delivery_total.
Cart / Order Placed / Account
src/app/.../(storefront)/cart/page.tsx, src/app/.../(checkout)/order-placed/[id]/page.tsx, src/app/.../(storefront)/account/page.tsx
Order summary and order-placed pages now show delivery_total/display_delivery_total and text updated from "ship/shipments"→"delivery/deliveries".
Product & Gift Cards
src/app/.../products/[slug]/ProductDetails.tsx, src/app/.../account/gift-cards/page.tsx
Product variant filtering changed (filter(Boolean) vs excluding master variants); gift card status reads card.status instead of card.state.
Analytics
src/lib/analytics/gtm.ts
GTM purchase payload sources order.delivery_total instead of order.ship_total.

Sequence Diagram(s)

sequenceDiagram
  participant User as User (UI)
  participant UIComp as DeliveryMethodSection
  participant Page as Checkout Page Handler
  participant DataLayer as src/lib/data/checkout.selectDeliveryRate
  participant SDK as `@spree/sdk.selectDeliveryRate`
  participant API as Server/API

  rect rgba(200,200,255,0.5)
  User ->> UIComp: choose delivery rate (rateId)
  UIComp ->> Page: onDeliveryRateSelect(fulfillmentId, rateId)
  Page ->> DataLayer: selectDeliveryRate(cartId, fulfillmentId, rateId)
  DataLayer ->> SDK: selectDeliveryRateSdk(cartId, fulfillmentId, rateId)
  SDK ->> API: POST /cart/:id/fulfillments/:id/select_rate
  API -->> SDK: 200 OK
  SDK -->> DataLayer: success response
  DataLayer -->> Page: updated cart/order
  Page -->> UIComp: refresh state / show processing result
  end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

Poem

🐰 A hop, a tweak, a delivery cheer,
Code refactored, the path is clear.
Shipments hopped off, fulfillments arrive,
Rates selected—our checkout’s alive! 📦✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: upgrading to Spree SDK 0.12.0, which triggers the comprehensive updates to shipment/shipping terminology (fulfillments/delivery) throughout the codebase.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/spree-sdk-0-12
📝 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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/app/[country]/[locale]/(storefront)/products/[slug]/ProductDetails.tsx (1)

32-40: Initializer fallback is redundant after Line 33 guard

After the early return at Line 33, return product.default_variant || null is unreachable as a “default variant” path and effectively just returns null. Consider simplifying to reduce ambiguity.

Cleanup diff
-  // Initialize with default variant or first available variant
+  // Initialize with default variant or first available purchasable variant
   const [selectedVariant, setSelectedVariant] = useState<Variant | null>(() => {
     if (product.default_variant) {
       return product.default_variant;
     }
     if (hasVariants) {
       return variants.find((v) => v.purchasable) || variants[0];
     }
-    // For products without variants, use default variant
-    return product.default_variant || null;
+    return null;
   });
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/app/`[country]/[locale]/(storefront)/products/[slug]/ProductDetails.tsx
around lines 32 - 40, The initializer for selectedVariant contains a redundant
final fallback ("return product.default_variant || null") that can never add
value because product.default_variant is already handled earlier; update the
initializer in the selectedVariant useState (the function passed to useState) to
simply: if (product.default_variant) return product.default_variant; if
(hasVariants) return variants.find(v => v.purchasable) || variants[0]; return
null; — i.e., remove the redundant product.default_variant || null and return
plain null for the no-variant case so the logic is unambiguous.
src/lib/data/checkout.ts (1)

64-75: Mark intentionally unused cartId parameters to avoid ambiguous API intent.

Line 64 and Line 72 accept cartId but do not use it. If this is intentional for signature compatibility, prefix with _ to make that explicit and keep lint/readability clean.

♻️ Proposed fix
-export async function getFulfillments(cartId: string) {
+export async function getFulfillments(_cartId: string) {
@@
 export async function selectDeliveryRate(
-  cartId: string,
+  _cartId: string,
   fulfillmentId: string,
   deliveryRateId: string,
 ) {
As per coding guidelines: "Remove unused variables and imports. If intentionally unused, prefix parameters with underscore."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/lib/data/checkout.ts` around lines 64 - 75, The functions getFulfillments
and selectDeliveryRate declare a cartId parameter that is not used; to make the
intent explicit and satisfy linting, rename those parameters to _cartId (i.e.,
change the signature of getFulfillments(cartId: string) and
selectDeliveryRate(cartId: string, fulfillmentId: string, deliveryRateId:
string) to use _cartId) so callers/signatures remain compatible while marking
the parameter as intentionally unused; update any internal references (none
expected) and keep the rest of the function body unchanged.
🤖 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/app/`[country]/[locale]/(storefront)/account/orders/[id]/page.tsx:
- Around line 332-338: The FulfillmentBlock is receiving the full order.items
array for every fulfillment, causing duplicate line items; update the
FulfillmentBlock instantiation in the order.fulfillments.map to pass only items
belonging to that fulfillment (e.g., derive itemsForFulfillment by filtering
order.items against the fulfillment's associated item ids or fulfillment.items
field) and pass that filtered array as the lineItems prop instead of
order.items; locate the map over order.fulfillments and replace
lineItems={order.items || []} with lineItems={/* filtered items for this
fulfillment */} referencing fulfillment.id or
fulfillment.line_item_ids/fulfillment.items as appropriate.

In `@src/app/`[country]/[locale]/(storefront)/products/[slug]/ProductDetails.tsx:
- Around line 23-26: The current useMemo for "variants" uses filter(Boolean)
which lets master variants through and causes broken matching/purchasability in
VariantPicker; change the filter to explicitly exclude master variants (e.g.,
filter(v => v && !v.isMaster && !v.master)) so only real sellable variants from
product.variants are returned, then pass that filtered "variants" into
VariantPicker as before; keep the same dependency array ([product.variants]).

---

Nitpick comments:
In `@src/app/`[country]/[locale]/(storefront)/products/[slug]/ProductDetails.tsx:
- Around line 32-40: The initializer for selectedVariant contains a redundant
final fallback ("return product.default_variant || null") that can never add
value because product.default_variant is already handled earlier; update the
initializer in the selectedVariant useState (the function passed to useState) to
simply: if (product.default_variant) return product.default_variant; if
(hasVariants) return variants.find(v => v.purchasable) || variants[0]; return
null; — i.e., remove the redundant product.default_variant || null and return
plain null for the no-variant case so the logic is unambiguous.

In `@src/lib/data/checkout.ts`:
- Around line 64-75: The functions getFulfillments and selectDeliveryRate
declare a cartId parameter that is not used; to make the intent explicit and
satisfy linting, rename those parameters to _cartId (i.e., change the signature
of getFulfillments(cartId: string) and selectDeliveryRate(cartId: string,
fulfillmentId: string, deliveryRateId: string) to use _cartId) so
callers/signatures remain compatible while marking the parameter as
intentionally unused; update any internal references (none expected) and keep
the rest of the function body unchanged.
🪄 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: bbb7f8b9-d2c5-43dd-9742-789676af3f1a

📥 Commits

Reviewing files that changed from the base of the PR and between 0293b2c and f5b9dda.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (15)
  • 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)/account/gift-cards/page.tsx
  • src/app/[country]/[locale]/(storefront)/account/orders/[id]/page.tsx
  • src/app/[country]/[locale]/(storefront)/account/orders/page.tsx
  • src/app/[country]/[locale]/(storefront)/account/page.tsx
  • src/app/[country]/[locale]/(storefront)/cart/page.tsx
  • src/app/[country]/[locale]/(storefront)/products/[slug]/ProductDetails.tsx
  • src/components/checkout/DeliveryMethodSection.tsx
  • src/components/checkout/Summary.tsx
  • src/components/checkout/index.ts
  • src/lib/analytics/gtm.ts
  • src/lib/data/__tests__/checkout.test.ts
  • src/lib/data/checkout.ts

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Caution

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

⚠️ Outside diff range comments (1)
src/app/[country]/[locale]/(storefront)/account/orders/[id]/page.tsx (1)

205-238: ⚠️ Potential issue | 🟡 Minor

Align tracking-related field checks for consistency.

Line 205 checks fulfillment.tracking_url to enable the Track button, while line 234 checks !fulfillment.tracking to show the "No tracking information" message. While these are separate fields in the Fulfillment type (tracking is the number/code and tracking_url is the derived tracking link), using them interchangeably for related logic creates a maintainability risk.

Consider checking the same field for both conditions (preferably tracking_url since it's the actionable link), or add a comment explaining the intentional semantic difference. This prevents edge cases where the fields could drift out of sync without visibility.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/app/`[country]/[locale]/(storefront)/account/orders/[id]/page.tsx around
lines 205 - 238, The tracking logic mixes fulfillment.tracking_url (used to
enable the "Track Items" link) and fulfillment.tracking (used to decide whether
to show "No tracking information"), which risks inconsistent behavior; update
the checks to use the same field (preferably fulfillment.tracking_url since it's
the actionable link) in both places—i.e., change the conditional that currently
tests !fulfillment.tracking to test !fulfillment.tracking_url—or, if there is an
intentional semantic difference, add a brief inline comment near the two
conditionals explaining why tracking and tracking_url are treated differently so
future maintainers won’t conflate them (affecting the conditionals that
reference fulfillment.status, fulfillment.tracking_url, and
fulfillment.tracking).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/app/`[country]/[locale]/(storefront)/account/orders/[id]/page.tsx:
- Around line 205-238: The tracking logic mixes fulfillment.tracking_url (used
to enable the "Track Items" link) and fulfillment.tracking (used to decide
whether to show "No tracking information"), which risks inconsistent behavior;
update the checks to use the same field (preferably fulfillment.tracking_url
since it's the actionable link) in both places—i.e., change the conditional that
currently tests !fulfillment.tracking to test !fulfillment.tracking_url—or, if
there is an intentional semantic difference, add a brief inline comment near the
two conditionals explaining why tracking and tracking_url are treated
differently so future maintainers won’t conflate them (affecting the
conditionals that reference fulfillment.status, fulfillment.tracking_url, and
fulfillment.tracking).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 43d7433a-4ee1-4f9a-99da-375c093b5517

📥 Commits

Reviewing files that changed from the base of the PR and between f5b9dda and 393ac9d.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (1)
  • src/app/[country]/[locale]/(storefront)/account/orders/[id]/page.tsx

@damianlegawiec damianlegawiec merged commit 98c8145 into main Mar 17, 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