Skip to content

Keep charging for express shipping on free-shipping orders - #29

Open
sergical wants to merge 1 commit into
releasefrom
fix/free-shipping-standard-only
Open

sergical wants to merge 1 commit into
releasefrom
fix/free-shipping-standard-only

Conversation

@sergical

Copy link
Copy Markdown
Member

Free shipping over the threshold now covers standard shipping only, so express orders still pay for express. The threshold also moves into a named constant, and there are two tests for checkoutTotal.

Created with Claude Code

Co-authored-by: Claude <claude@anthropic.com>
@github-actions

Copy link
Copy Markdown

Verdict: Approve with minor suggestions (no blocking issues).

Tests pass (18/18, 2 files). The actual diff is correct; it does not contain a duplicated shippingCharge line — that artifact only showed up in a note I added for one of the sub-reviewers transcribing the diff and does not exist in fixtures/latest.diff or the final file content, so disregard that part of the correctness pass.

Correctness

  • The core logic change is intentional and correct: freeShipping = subtotal >= FREE_SHIPPING_THRESHOLD && !cart.express makes express orders always pay shipping, even above the $100 threshold. This is a genuine behavior change from the previous rule (any order ≥ $100 shipped free, express included). It's covered by the new tests and passes, but it is a customer-facing pricing change — worth a one-line comment or changelog note confirming this is the desired business rule, not an accidental regression.
  • Test coverage gap: no test exists for an express order under the threshold (should still charge, same as before) or for the exact boundary (subtotal === 100). Adding these would lock in the intended behavior and guard the threshold comparison (>= vs >).
  • Pre-existing, not introduced by this diff: no bounds-checking on taxRate or discount.percent, which could theoretically produce negative totals. Not blocking, just a note for future hardening.

Style

  • freeShipping as a name now conflates "over threshold" with "not express." Consider renaming to qualifiesForFreeShipping or adding a short comment, since the express exception isn't obvious from the variable name alone.
  • FREE_SHIPPING_THRESHOLD is declared between the Cart type and roundCents, away from its only use in checkoutTotal. Minor locality improvement: move it closer to where it's used, or group with other shipping-related constants if more appear later.
  • Minor wording nit: the test title 'ships standard orders over the threshold for free' reads a little awkwardly — something like 'applies free shipping to standard orders above the threshold' would be clearer.

Overall this is a small, well-tested, low-risk change. The only thing worth confirming before merge is that excluding express orders from free shipping is the intended product decision.

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