Skip to content

Feat/drgreen flex readiness - #289

Merged
AutomatosAI merged 6 commits into
mainfrom
feat/drgreen-flex-readiness
Oct 5, 2026
Merged

AutomatosAI merged 6 commits into
mainfrom
feat/drgreen-flex-readiness

Conversation

@AutomatosAI

Copy link
Copy Markdown
Owner

No description provided.

…r Green's delivery (BS-F01)

The localStorage basket kept the add-to-cart price with no TTL, so checkout
could show a price Dr Green no longer charges. Checkout now re-reads the
tenant's catalogue on load and whenever the basket contents change, writes
live prices back to the store, flags moved lines "Price updated" and
removes lines no longer listed with a message.

The summary shows subtotal, Dr Green's delivery charge (new
GET /api/store/[slug]/checkout/quote, read off the customer's own server
cart) or "Calculated by Dr Green", and the total; Place Order includes
delivery.

GET /dapp/carts ignores clientId and lists every client of the key with a
cart, so getCart read another customer's cart via clients[0]. Both getCart
and the quote now pick the customer's cart by id (pickClientCart).

Copies the PRD to tasks/prd-drgreen-commission-flex.md with a status section.
…owser (BS-F02)

submitOrder wrote orders.subtotal/total and order_items.price from the
prices the browser sent, so history, confirmation, analytics and packing
slips showed storefront-computed totals. It now takes subtotal from Dr
Green's stored totalAmount and prices each line from GET /dapp/orders/:id
(localPrice.productAmount is the line total, so price = amount / grams).
If that read fails the line falls back to the server-fetched live
catalogue; the browser price is only compared and logged at warn.

syncOneOrder mirrors Dr Green's totals when they differ, reading the local
localPrice.totalAmount and the stored deliveryCharge. orderDetails.totalAmount
is not used: Dr Green's reader overwrites it with the USD base sum.
…BS-F03)

fetchProduct cached the normalised catalogue under ${country}:${apiUrl},
so once Dr Green Commission Flex gives each KEY its own price, one
tenant's product page metadata and JSON-LD Offer.price could carry
another tenant's price for up to 60s. The key now starts with a SHA-256
prefix of the API key; platform-key fallback tenants share the platform
entry, and invalidateProductCache still clears every entry. Cache moved
to lib/drgreen/product-cache.ts.
The product page rendered -X% OFF whenever product.discount was set. Dr
Green never sends it today, but Commission Flex gives holders their own
price and the Flex PRD rules out any was/now, badge or percentage-off on a
storefront. Badge removed with a pointer to the non-goals; discount
dropped from the UI product type. No strike-through price styling exists;
a source-scan test now guards app/store and the storefront components.
…BS-F01, BS-F02)

- syncOneOrder mirrors the line-items total only while payment is PENDING:
  Dr Green's reader recomputes localPrice from today's price until the
  line-price snapshot ships, so a paid order must not move retroactively.
  The stored deliveryCharge is still always mirrored.
- Redact the search param (customer email) from the Dr Green request log.
- Show a delivery quote only when its currency matches the basket's.
- A live price of 0 removes the basket line instead of showing it free.
- Discard catalogue fallback prices that do not reconcile with Dr Green's
  total in favour of the per-gram share of that total.
- getCart narrows GET /dapp/carts by the customer's email.
…S-F01)

normalizeProduct keeps strainLocations[].location.deliveryCharge (new on
/dapp/strains with the Dr Green delivery hotfix) as deliveryCharge +
deliveryCurrency. null means the market has none set, so Dr Green bills its
default 6 in the market currency and that is what is shown; an absent field
(older backend) means unknown.

Checkout shows the catalogue charge when it is in the basket's currency, else
the server-cart quote (unchanged, now the fallback), else "Calculated by Dr
Green". Pure selection in lib/checkout/delivery-charge.ts with unit tests.
@coderabbitai

coderabbitai Bot commented Oct 5, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b54d7ea3-75ca-46bb-8cfd-b85c1b79e8b0
📥 Commits

Reviewing files that changed from the base of the PR and between 7b9620d and de05780.

📒 Files selected for processing (29)
  • nextjs_space/app/api/store/[slug]/checkout/quote/route.ts
  • nextjs_space/app/api/store/[slug]/orders/submit/route.ts
  • nextjs_space/app/store/[slug]/checkout/checkout-order-summary.tsx
  • nextjs_space/app/store/[slug]/checkout/page.tsx
  • nextjs_space/app/store/[slug]/checkout/use-checkout-pricing.ts
  • nextjs_space/app/store/[slug]/products/[id]/product-detail-client.tsx
  • nextjs_space/app/store/[slug]/products/[id]/product-detail-types.ts
  • nextjs_space/lib/cart-store.ts
  • nextjs_space/lib/checkout/delivery-charge.ts
  • nextjs_space/lib/checkout/reprice-basket.ts
  • nextjs_space/lib/drgreen/delivery-quote.ts
  • nextjs_space/lib/drgreen/delivery.ts
  • nextjs_space/lib/drgreen/doctor-green-api.ts
  • nextjs_space/lib/drgreen/drgreen-api-client.ts
  • nextjs_space/lib/drgreen/drgreen-cart.ts
  • nextjs_space/lib/drgreen/drgreen-orders.ts
  • nextjs_space/lib/drgreen/order-pricing.ts
  • nextjs_space/lib/drgreen/product-cache.ts
  • nextjs_space/lib/orders/storefront-orders.ts
  • nextjs_space/tests/unit/checkout-delivery-charge.test.ts
  • nextjs_space/tests/unit/checkout-reprice-basket.test.ts
  • nextjs_space/tests/unit/delivery-quote.test.ts
  • nextjs_space/tests/unit/drgreen-log-redaction.test.ts
  • nextjs_space/tests/unit/no-discount-presentation.test.ts
  • nextjs_space/tests/unit/order-pricing.test.ts
  • nextjs_space/tests/unit/product-cache-tenant-scope.test.ts
  • nextjs_space/tests/unit/storefront-orders-sync-totals.test.ts
  • nextjs_space/tests/unit/submit-order-pricing.test.ts
  • tasks/prd-drgreen-commission-flex.md
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@AutomatosAI
AutomatosAI merged commit 9bc7076 into main Oct 5, 2026
6 of 7 checks passed
apiUrl?: string;
requestId?: string;
}): Promise<OrderPricing> {
const { orderData, items, catalogueUnitPrices, apiKey, secretKey, apiUrl, requestId } = params;

/** A stable, non-reversible id for the key that fetched a catalogue. */
export function tenantKeyId(apiKey: string): string {
return createHash("sha256").update(apiKey).digest("hex").slice(0, 16);
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.

3 participants