Repository navigation
Feat/drgreen flex readiness - #289
Merged
Merged
Conversation
…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.
|
Warning Review limit reachedYou'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. View limit detailsLimit details: You’ve used the included review currently available. Review configuration: ⚙️ Run configuration
📒 Files selected for processing (29)
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. Comment |
| 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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.