WooCommerce Flat Rate Shipping Formula Builder
Build [qty], [cost] and [fee] formulas and shipping class costs, then test them on sample carts before you paste them in.
Your details
Paste these into the Flat rate settings
Cost: 5 + [fee percent="10" min_fee="4" max_fee="20"]
"Heavy" shipping class cost: 8 * [qty]
"Small" shipping class cost: (leave blank)
No shipping class cost: (leave blank)
Calculation type: Per class: Charge shipping for each shipping class individuallySample carts: quantity and price per item, excluding tax
| Cart | Heavy (qty, price) | Small (qty, price) | No class (qty, price) | Items cost | Shipping | ||||
|---|---|---|---|---|---|---|---|---|---|
| Cart A | 25.00 | 9.00 | |||||||
| Cart B | 120.00 | 17.00 | |||||||
| Cart C | 180.00 | 31.00 | |||||||
| Cart D | 380.00 | 41.00 | |||||||
Cart A: 1 item, items cost 25.00. Main cost 9.00 · No class N/A (blank) = 9.00
Cart B: 3 items, items cost 120.00. Main cost 17.00 · No class N/A (blank) = 17.00
Cart C: 3 items, items cost 180.00. Main cost 23.00 · “Heavy” class 8.00 · “Small” class N/A (blank) = 31.00
Cart D: 4 items, items cost 380.00. Main cost 25.00 · “Heavy” class 16.00 · No class N/A (blank) = 41.00
Paste each line into WooCommerce → Settings → Shipping → (your zone) → Edit on the Flat rate method. Class cost fields only appear once you've created shipping classes.
The placeholders WooCommerce understands
| Placeholder | Means | Example |
|---|---|---|
[qty] | Number of items that need shipping | 10 + ( 2 * [qty] ) |
[cost] | Cost of those items, before tax and after coupons | [cost] * 0.05 |
[fee percent="10"] | 10% of the items' cost, rounded to your price decimals | 10 + [fee percent="10"] |
min_fee, max_fee | Floor and ceiling for the percentage fee only | [fee percent="10" min_fee="4" max_fee="20"] |
Formulas can use + - * / and brackets. In a shipping class cost field, [qty] and [cost] count only the items in that class. The main Cost field is added to the class costs, and Calculation type decides whether every class is charged (per class) or only the most expensive one (per order).
Worked example
5 + [fee percent="10" min_fee="4" max_fee="20"], the Heavy class costs 8 * [qty], and Calculation type is per class.Cart C: 1 Heavy item at $150, 2 Small items at $15
- Items cost ([cost])
- $180.00
- 10% fee (between $4 and $20)
- $18.00
- Main cost: 5 + 18
- $23.00
- Heavy class: 8 × 1
- $8.00
- Small class (blank)
- nothing
Shipping: $31.00. Cart D ($380 of items) hits the $20 cap: 5 + 20 + (8 × 2) = $41.00.
Setting it up in WooCommerce
- 01
Create shipping classes first
Go to WooCommerce → Settings → Shipping → Classes and add classes like Heavy or Small. Class cost fields only appear in Flat rate once classes exist.
- 02
Assign classes to products
In each product's Shipping tab, pick the class. Variations can have their own class.
- 03
Paste the formulas
Go to WooCommerce → Settings → Shipping → Shipping zones, edit a zone, then edit (or add) the Flat rate method and paste each line into its field.
- 04
Test a real cart
Add products to the cart as a customer and compare the rate with the simulator.
Pitfalls
- Blank isn't free. A blank class cost means N/A (nothing added). Enter
0only if you mean zero. - Curly quotes break [fee]. Copying from a word processor turns
"into”. Type straight quotes. - min_fee and max_fee only limit the [fee] part, not the whole formula.
- Per order ignores cheaper classes, so a cart with Heavy and Small items pays only the Heavy class cost plus the main cost.
Questions people ask
How do I charge per item in WooCommerce?
Use [qty]. For $5 per order plus $1.50 per item, the cost is 5 + ( 1.5 * [qty] ).
Can flat rate charge a percentage of the order?
Yes, with [fee percent="10"]. Add min_fee and max_fee to keep it between two amounts.
Does [cost] include tax or coupons?
It's the item cost before tax and after coupon discounts, for items that need shipping. Virtual items don't count.
Why doesn't my flat rate show at checkout?
If every cost field is blank, WooCommerce doesn't offer the rate. Also check the customer's address matches the shipping zone.
Can I base flat rate on weight?
Not in current stable WooCommerce. Use shipping classes as weight bands, or a table rate shipping extension.
Related tools
Last reviewed 30 September 2026.
Sources: WooCommerce docs: Flat rate shipping · WooCommerce docs: Product shipping classes · WooCommerce source: WC_Shipping_Flat_Rate (how costs are evaluated)
