N NoBullshit.wiki 中文

Bookstore cashier - discount-stacking calculator, single-file tool - when member discount, store promotion, publisher deal, and coupon all land on one basket, it enumerates every legal combination under the store's own configured stacking rules and takes the lowest compliant price, outputting the number and a read-aloud explanation line together; no default discount rates ship inside - the rules belong to the manager, not the tool

Works with:Claude / GPT-4 classCategories:BookstoreLevel:Intermediate Updated

Build a single-file HTML tool for a bookstore (no dependencies, works
offline, opens in the register browser): when several discount sources
stack on one basket, compute the amount due under the store's own
configured stacking rules, and generate one sentence the cashier can read
aloud to the customer.

Background: a single basket can carry four discount sources at once -
1. Member discount (by member tier, store-wide or by category)
2. Store promotion (spend-X-save-Y or spend-X-percent-off, store-wide or
   by category)
3. Publisher promotions (attached to specific titles, per-book)
4. Coupons (customer-presented, one per basket)

Rules configuration page (the manager enters once; the checkout page only
uses):
- For every pair of discount sources, mark one relation: stackable / or
  mutually exclusive (when exclusive, the basket resolves that pair by
  whichever is best for the customer)
- Coupon timing: does the threshold check against pre-discount or
  post-discount totals
- The tool presets no default relations and ships with no discount-rate
  numbers; rules exist only once the manager enters them

Checkout page:
- Line entry: title or scanned price, quantity, unit price, publisher
  deal flag (choose the specific deal tier)
- Select member tier (or none) and the coupon (or none)
- Algorithm: under the configured stacking relations, enumerate every
  legal discount combination for this basket and take the lowest
  compliant total
- The result outputs two things, never one without the other:
  a. Amount due plus line detail (each line's list price, which discounts
     it hit, the discounted amount)
  b. One spoken explanation, colloquial and complete, generated from the
     discounts actually applied - e.g. "these two are on the publisher
     deal, and with your member card it comes to XX." The explanation
     must match the combination the algorithm actually used; a discount
     that didn't fire may not appear in it

Explicitly not built:
- No industry-default discount rates or stacking relations - empty
  configuration to start; rules exist only when entered
- No member stored value, no POS integration, no network, no uploads
- Clicking "new basket" clears everything; the only localStorage is the
  rules configuration - transaction records are never stored
- No "suggest signing up for membership" marketing lines - the tool
  computes and explains, nothing else

Why it is written this way

Bookstore checkout ranks near the top of retail for discount density: discounting books is the industry's resting state (prices are nominal, discounts are the norm), and member tiers, publisher deals, and coupons pile on top - four sources in one basket is routine. The cashier's mental load and the customer's suspicion rise together: the customer watches the screen while the cashier punches a calculator and explains, and the moment the explanation and the number diverge, the dispute starts. Hence the tool's paired output: the number and the read-aloud line. Most register disputes were never about arithmetic (arithmetic can be corrected) - they're about intelligibility. When "why is it this amount" goes unanswered, the customer defaults to assuming a rip-off.

Making stacking relations a manager configuration rather than built-in policy is the tool's most important decision. Whether discounts stack has no industry-standard answer: some stores make member and promotion mutually exclusive, others resolve to the customer's best outcome - both strategies are legitimate, and a tool that picks for the store has overstepped. Practically, the configuration page stores rules and only rules - rules are store property, transactions are customer privacy, and separating the two makes "the register is a shared computer" an acceptable reality.

Enumerating all legal combinations rather than hard-coding one calculation order exists because combinatorial explosion is exactly what humans can't compute. Four sources with exclusivity woven in can yield seven or eight legal combinations; a person computes one - usually the path memorized, which is neither guaranteed optimal for the customer nor guaranteed legal for this basket. The machine enumerates: compliance (no exclusive pair violated) and optimality (lowest in-rule price) hold at once - and only then does the explanation line dare to be read aloud, because every discount named in it actually fired.

Variables

Variable Description
Stacking-relation matrix The manager enters each pair (member × promotion, member × publisher deal, promotion × coupon, publisher deal × coupon...) on the configuration page. Re-verify before every major campaign - when promotions change rules ad hoc and the configuration lags, the tool computes wrong answers with perfect confidence
Coupon timing convention Pre-discount or post-discount threshold, matching how coupons actually redeem inside the POS - where the two disagree, the POS wins and the tool's explanation follows the POS's actual deduction

checkoutpromotionssingle-file-tool