Overview
A calculator works out an amount. “Charge $5 per item.” “Take 15% off.” “Free over $50, otherwise $7.” They exist because the rule and the number are different questions. A promotion decides whether a discount applies; a calculator decides how much. Keeping them apart means a merchant can change “10% off” to “$10 off” without touching the conditions that decide who qualifies. Two things use calculators:- Delivery methods — what delivery costs
- Promotions — how big a discount is
Tax does not use calculators. Tax is worked out by a tax provider, which can be Spree’s own rate tables or an external service.
Choosing a calculator
Each calculator takes a few settings — the amount, the percentage, the threshold. A merchant picks one and fills in the settings when setting up a delivery method or a promotion.For delivery charges
For promotion discounts
Worked examples
Free delivery over $50, otherwise $7
Free delivery over $50, otherwise $7
Price sack, with
minimal_amount: 50, discount_amount: 0, normal_amount: 7.A $60 basket pays nothing. A $20 basket pays $7.$3 to ship the first item, $1 for each extra
$3 to ship the first item, $1 for each extra
Flexi rate, with
first_item: 3, additional_item: 1.Four items cost $3 + (3 × $1) = $6. Set max_items to stop charging beyond a point.10% off the order
10% off the order
Percent of item total, with
flat_percent: 10.A $31 order gets $3.10 off.Spend more, save more
Spend more, save more
Tiered percent — 5% over $100, 10% over $250, 15% over $500.The order total picks the tier. One promotion covers the whole ladder instead of three competing ones.
Setting one up
Calculators are configured as part of the thing that uses them. The available calculators for each are discoverable, so a dashboard or a script can present the real list rather than a hardcoded one:Writing your own
When none of the built-in calculators expresses your pricing — dimensional weight, a contract rate card, a rule your finance team invented — you can add one. A calculator is a small class with a name and a method that returns an amount, registered so it appears alongside the built-in options. For delivery specifically, consider whether you want a calculator or a delivery rate provider. A calculator computes a number from what’s in the parcel. A provider asks a carrier for real, live rates. If you want what UPS would actually charge today, that’s a provider. See Custom promotions and Providers.Related
- Fulfillments — delivery methods and rates
- Promotions — the rules that decide when a discount applies
- Discounts — the rows a promotion produces
- Taxes — worked out by providers, not calculators

