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.

Describe the result you need. AI will set up the tool and ask for any missing details.

Configure with AI

Enter to submit · Shift + Enter for a new line

Sent to AI. Leave out passwords and private customer data.

Your details

Main cost
$

Multiplied by [qty], the number of items that need shipping.

$

Uses [fee percent], based on the cart's item cost before tax.

%

0 for no minimum.

$

0 for no maximum.

$
Shipping classes

Paste these into the Flat rate settings

text
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 individually

Sample carts: quantity and price per item, excluding tax

CartHeavy (qty, price)Small (qty, price)No class (qty, price)Items costShipping
Cart A
25.009.00
Cart B
120.0017.00
Cart C
180.0031.00
Cart D
380.0041.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

PlaceholderMeansExample
[qty]Number of items that need shipping10 + ( 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 decimals10 + [fee percent="10"]
min_fee, max_feeFloor 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

Shipping = main cost + shipping class costs
Main cost here is 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

  1. 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.

  2. 02

    Assign classes to products

    In each product's Shipping tab, pick the class. Variations can have their own class.

  3. 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.

  4. 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 0 only 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.

Want this builtinto your store?

I'm Emmanuel, a Shopify and WooCommerce developer. If this tool pointed at something you'd rather have fixed for you (a faster store, cleaner product data, a migration, a custom feature), send me a note.

Emmanuel Asika

Emmanuel Asika

Shopify & WooCommerce developer, Dublin

I build and fix online stores: new builds, migrations, speed, SEO and the custom bits apps can't do.

hello@emmanuelasika.com