Snack shop marketing planner - bulk spend-threshold promo calculator - single-file web tool, worst-case basket-filling must be computed, because average margin hides the blow-through
You are a coding agent building an internal tool for
a snack chain's marketing team. Build a single-file
HTML tool (all HTML, CSS, and JS inline, no external
dependencies, no network calls, opens by double-
click) for planners to model spend-threshold promos
on bulk snacks.
The hazard the tool exists for, stated in its
positioning: a threshold promo blows through margin,
and only the post-mortem shows the baskets were
filled with low-margin filler. Average-margin math
cannot see that blow-through. Computing it is this
tool's core job.
Input section:
- Item structure: for each bulk price band (per-
500 g price range) the item count, sales share,
and margin rate; same for packaged items
- Promo plan: spend [X] save [Y] or [N] items for
[Z]% off, scope (storewide / bulk only / whether
already-promoted items count)
- Typical basket distribution: share of tickets
below the threshold (an estimate, adjustable)
Calculations and output:
1. Average case: margin-weighted by each band's
sales share; discount cost as a share of sales -
the conventional math everyone already does
2. Worst-case basket-filling (the core of this
tool; mandatory, never omitted): assume every
incremental purchase made to reach the threshold
lands on the single lowest-margin band in scope;
recompute the actual promo margin - output one
large line: "worst-case promo margin rate is
[X]%"
3. Side-by-side comparison table: average case vs
worst case across plan variants (thresholds and
discount depths), one row each
4. Threshold recommendation line: the lowest
threshold that minimizes filler spend while
keeping worst-case margin at or above the
target rate
5. Method notes: every formula printed on the page,
numbers update as inputs change; no black box
Boundaries (printed on the page):
- No sales-lift forecasting - the tool computes the
margin safety floor only; "how much more will we
sell" is unknowable and the tool will not pretend
- No long-term traffic or brand value math - out
of scope for this tool
- An exportable "dangerous filler list": every item
in scope with margin below [X]% - so the planner
can decide which items to exclude from the promo
Hard requirements:
- Data stays on the machine (localStorage), with
export and reset
- Ships with sample data preloaded so the result is
visible on open
- No "smart plan recommendation" - sorting is fine,
decisions stay with the planner
Why it is written this way
The worst-case basket-fill is the tool's heart. A threshold promo's margin risk never lives in the average - it lives in the rational behavior of every customer independently solving "cheapest way to reach 38" and stacking into your lowest-margin band. Make that scenario a mandatory output rather than an option, and what the planner sees is the floor of the safety margin instead of a number smoothed flat by weighting.
No sales forecasting is the hard boundary. The most common way promo calculators overreach is appending "estimated 20% lift" - a number with no basis that then kidnaps the review meeting: miss the lift and the plan gets blamed for "poor execution." Cut the forecast and the tool answers only "does the worst case lose money," the one question it can answer reliably.
The exportable filler list keeps the next move inside the tool. The natural reaction to a bad worst-case number is "exclude the most dangerous items from the promo" - with the list generated, the planner moves from "knows there is risk" to "edits the plan" without an extra manual inventory pass in between.
Variables
| Variable | Description |
|---|---|
| Threshold and discount plan | Spend-X-save-Y or N-for-Z - the comparison table should show at least three variants side by side |
| Basket-fill assumption scope | How the eligible range is drawn and whether already-promoted items count toward the threshold - the worst case moves with the scope, so variants must share one definition |