Skip to content

feat(ecommerce): add live checkout quotes and discount administration - #350

Merged
olliethedev merged 6 commits into
mainfrom
feat/issue-340-after-v6
Nov 6, 2026
Merged

olliethedev merged 6 commits into
mainfrom
feat/issue-340-after-v6

Conversation

@olliethedev

@olliethedev olliethedev commented Nov 6, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Closes #340.

 checkout
+ preview authoritative subtotal - discount + shipping + tax
+ calculate shipping/tax again when creating the order
+ persist tax separately; retries reuse stored amounts and payment
 orders admin
+ Discount Codes tab: list usage, create, delete

Optional calculateShipping and calculateTax configuration functions receive authoritative prices and the shipping address. Static shippingAmount and zero tax remain the defaults. Net product revenue remains subtotal - discount. Preview does not reserve stock or discount uses. Discount administration requires ecommerce.discount.manage.

Evidence

  • Recovery candidate 52797bb5: a fresh React Router production build and a freshly generated Next.js production build each pass all 4 Ecommerce browser scenarios. Ecommerce's 42 unit tests, typecheck, dependency builds, and Biome on the corrected spec pass. Registry regeneration produces no diff. Independent Standards and Spec reviews each report zero findings.

  • The original lost-response test and the preparing-state-only correction both reproduced the React Router quote timeout. Its fixture caches queries for five minutes. The corrected test holds the successful checkout response until Preparing payment renders, advances browser fixed time past that cache window, then aborts delivery. The quote endpoint returns a real 400; retry uses the identical body/idempotency key, recovers the same order, and leaves exactly one discount use. Product query semantics are unchanged.

  • Before: Checkout supported static shipping, had no stored tax or live quote operation, and discount codes had no administrative list/delete interface.
    After: 42 ecommerce unit tests and all 4 smoke.ecommerce.spec.ts browser tests pass, covering recalculation, retry fingerprints, tampered input, rollback, legacy tax fallback, authorization, admin controls and both existing checkout flows.

  • The lost-response browser regression first reproduced a disabled payment button after the order consumed the discount's last use. It now proves recovery with the original idempotency key, the same order, and one discount use despite a fresh quote error.

  • Ecommerce build/typecheck and Biome on 50 relevant files pass. Registry output is regenerated and limited to Ecommerce and the index. The docs production build passed; the subsequent main merge contains release metadata/migration-doc updates, with targeted ecommerce checks rerun afterward.

  • Captioned demo (MP4), checkout screenshot, discount usage screenshot, mobile screenshot, full inspected evidence bundle. All 7 recording steps passed. Mobile overflow, keyboard tabs, fixed-code expiry, dark theme and quote-error retry were checked.

Media links are durable in the owner's archive and require the owner's website login plus LAN/private Tailscale access; they are not anonymous public GitHub uploads. Rates and products are demo data. The full local suite, TanStack browser run and complete multi-plugin packed-consumer matrix are left to CI. The recovery reran Ecommerce browser checks on both Next.js and React Router production; previous docs/media verification is historical and was not rerun for the test-only correction.

Merge Danger

Door: Two-way application rollback; the additive database column can remain.

Apply the ecommerceOrder.tax migration before deploying. Calculator failures reject checkout; transaction rollback retains stock/discount availability. Calculators should avoid purchase side effects and use bounded service timeouts.

Blast Radius: Checkout

@vercel

vercel Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
better-stack-docs Ready Ready Preview Nov 6, 2026 10:58am UTC
better-stack-playground Ready Ready Preview Nov 6, 2026 10:58am UTC

Request Review

@olliethedev

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-06T10:59:57.864516Z 52797bb Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 210916090d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@github-actions

github-actions Bot commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Bundle size

5 of 194 bundles changed.

Module Gzip base → PR Gzip change Minified change
@btst/plugin-ecommerce/client 164579 → 172554 B +7975 B (+4.8%) +23672 B (+3.5%)
@btst/plugin-ecommerce/client/components 197693 → 199703 B +2010 B (+1.0%) +7899 B (+1.0%)
@btst/plugin-ecommerce/api 109334 → 109964 B +630 B (+0.6%) +2716 B (+0.5%)
@btst/plugin-ecommerce/client/hooks 114055 → 114343 B +288 B (+0.3%) +1240 B (+0.2%)
@btst/plugin-ecommerce/query-keys 2512 → 2580 B +68 B (+2.7%) +378 B (+7.0%)

ad53b4c → 52797bb. Standalone costs; rows overlap. Moved paths appear as new/removed entries, not application savings.

Measured 22 packed archives separately; full report includes their compressed bytes without installed dependencies.

Full report and measurements

@olliethedev

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. 👍

Reviewed commit: ac92006e40

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@olliethedev

Copy link
Copy Markdown
Collaborator Author

@codex review

Candidate: 52797bb5d34f5f425c7300627d9966dfb37aa185 (includes current main ad53b4cf).

The React Router regression was waiting for a refetch while its fixture retained a fresh five-minute quote cache. Waiting for Preparing payment alone still reproduced the timeout. The test now holds the real successful checkout response until that state is visible, advances browser fixed time beyond the cache window, and aborts delivery. The real quote endpoint rejects with 400; retry keeps the identical body/key, same order and one discount use. Product query semantics are unchanged.

Fresh React Router and Next.js production builds each passed all four Ecommerce browser scenarios. All 42 Ecommerce unit tests, typecheck and targeted Biome pass; registry regeneration has no diff. Independent Standards, Spec and native Safeguard reviews found no issues. Generated fixture lockfile churn was preserved locally and excluded. Full-suite and packed-consumer verification remain CI-owned.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 52797bb5d3

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@olliethedev
olliethedev merged commit 8cb436f into main Nov 6, 2026
62 checks passed

This branch was successfully deployed

2 active deployments
Preview – better-stack-docs — 52797bb5 Deployed Nov 6, 2026 by vercel[bot]
Preview – better-stack-playground — 52797bb5 Deployed Nov 6, 2026 by vercel[bot]
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.

Ecommerce: dynamic tax/shipping calculation hooks and discount code admin UI

1 participant