Skip to content

perf(cart): reuse precomputed subtotals in checkout summary#6880

Open
wenhaog7 wants to merge 1 commit into
reactioncommerce:trunkfrom
wenhaog7:feat/cart-summary-tax-aware-subtotals-v4
Open

perf(cart): reuse precomputed subtotals in checkout summary#6880
wenhaog7 wants to merge 1 commit into
reactioncommerce:trunkfrom
wenhaog7:feat/cart-summary-tax-aware-subtotals-v4

Conversation

@wenhaog7

@wenhaog7 wenhaog7 commented Apr 8, 2026

Copy link
Copy Markdown

Summary
This PR optimizes cart summary calculation and improves cart query performance in checkout flows.
Changes

  • Reused precomputed item subtotals in xformCartCheckout when taxSummary is present, instead of always recalculating from unit price × quantity.
  • Refactored fulfillment and surcharge aggregation loops for simpler and more efficient summary computation.
  • Updated accountCartByAccountId resolver to decode opaque IDs once and reuse decoded values.
  • Added a short-lived cache hint (maxAge: 60) for accountCartByAccountId to reduce load from frequent cart polling.
    Why
  • Reduce repeated compute work on high-frequency cart reads.
  • Keep summary calculations aligned with transformed item-level data.
  • Improve responsiveness for storefront cart/checkout polling.
    Testing
  • Manual checkout smoke test with multi-item carts.
  • Verified cart query behavior with opaque and non-opaque IDs.
  • Confirmed API and storefront cart flow remain operational.
    Notes
  • No schema changes.
  • No migrations required.

@changeset-bot

changeset-bot Bot commented Apr 8, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 445fce3

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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