Document cart totals caching (spec 0076) - #50
Open
glennjacobs wants to merge 1 commit into
Open
glennjacobs wants to merge 1 commit into
glennjacobs wants to merge 1 commit into
Conversation
Companion to lunarphp/lunar#2721 (spec 0076). Adds the persisted totals snapshot columns to the Cart and CartLine field tables, documents the calculate() decision order, the freshness rule, lunar.cart.totals.ttl, invalidation paths, the write guard and the total column shadowing, and covers the new CalculatesCart / HydratesCartTotals / PersistsCartTotals contracts with a rebinding example. Payment drivers read totals through recalculate(). Upgrade guide gains the data migration and the behavioural note for calculate() and updateLine(). Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
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.
Summary
Companion to lunarphp/lunar#2721, which implements spec 0076 (cart totals caching in the database). Documents the persisted totals snapshot on the v2 carts pages and the behaviour changes downstream code needs to know about.
Changes
2.x/reference/carts.mdx— snapshot columns added to theCart(15) andCartLine(9) field tables in schema order; the overview callout no longer says totals are not stored;calculate()now documented as memo, then fresh snapshot, then pipeline, withrecalculate()for guaranteed-fresh totals; new Persisted totals section (freshness rule,lunar.cart.totals.ttl,totalsAreFresh()/invalidateTotals(),totalcolumn shadowing) and Invalidation section (per-change mechanism table, write guard, activity-log exclusion);setCurrency()wording updated to the refresh behaviour.2.x/extending/carts.mdx—CalculatesCart,HydratesCartTotals,PersistsCartTotalsadded to the contract table; new Totals caching section explaining that persistence lives in the action rather than a pipe, with a rebinding example that switches the snapshot off, and a warning about query-builder writes needinginvalidateTotals().2.x/extending/payments.mdx— the amount guard example reads the cart throughrecalculate(), with the reasoning.2.x/guides/cart.mdx— the "calculated on demand" callout now points at the persisted totals section.2.x/getting-started/overview/upgrade-guide.mdx—add_cart_totals_columnsdata migration listed; manual checklist item forcalculate()possibly serving persisted totals andupdateLine()now firing model events.2.x/getting-started/setup/system-settings.mdx—config/lunar/cart.phppurpose mentions the totals TTL.No new pages, so
docs.jsonis unchanged.Verification
mint validatepasses (strict build).mint broken-linkspasses.CalculateCartWithoutSnapshotexample was run against the monorepo branch in a throwaway Pest test: the rebinding calculates the cart and leavestotal/calculated_revisionnull on the row.lunarphp/lunarfeat/cart-totals-caching.Should merge after lunarphp/lunar#2721.
🤖 Generated with Claude Code