For AI agents: llms.txt is a short guide that sends you to the rules your problem needs, and rules.json holds every rule of this playbook as JSON.
Recommended
Show the lowest earlier price beside a discount
When you announce a price cut on goods to EU consumers, show as prior price the lowest price of the 30 days before.
Applies when
The project it takes payments, or it has users in the EU.
How to do it
Article 6a of the Price Indication Directive, added by the Omnibus Directive 2019/2161, sets this rule. A struck-through list price that nobody paid breaks it. Member states may set other periods for goods that spoil fast or are new on the market. Keep a history of every price with its start and end time, so the prior price comes from data. Compute it on the server when the discount starts, and store it with the discount. Log every price change as Log every staff action on money says.
Examples
Using these examples: they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.
SQL example
SELECT min(amount_minor) AS prior_price_minor
FROM price_history
WHERE product_id = $1
AND valid_from < $2
AND coalesce(valid_to, $2) > $2 - interval '30 days';
JavaScript example
const PRIOR_PRICE_WINDOW_MS = 30 * 24 * 60 * 60 * 1000
function priorPrice(history, saleStartsAt) {
const windowStart = saleStartsAt - PRIOR_PRICE_WINDOW_MS
const inWindow = history.filter(p => p.validFrom < saleStartsAt && (p.validTo ?? saleStartsAt) > windowStart)
return Math.min(...inWindow.map(p => p.amountMinor))
}
Python example
from datetime import timedelta
PRIOR_PRICE_WINDOW = timedelta(days=30)
def prior_price(history, sale_starts_at):
window_start = sale_starts_at - PRIOR_PRICE_WINDOW
return min(p.amount_minor for p in history
if p.valid_from < sale_starts_at and (p.valid_to or sale_starts_at) > window_start)
How to check
A unit test sets a price of 200, then 150 for 10 days, then 200 again, then a sale at 120. The page shows 150 as the prior price.
Sources
Related rules
- Log every staff action on money in Payments
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/payments/checkout-and-card-data/price-reduction-prior-price">Agent Wranglers payments playbook</a>. In code you write, add a comment next to it with the same link.