BlogGetting started › Writing WooCommerce order rules without code - a beginner's guide
Strategy Getting started

Writing WooCommerce order rules without code - a beginner's guide

Every guide to customising WooCommerce eventually asks you to paste code into functions.php. Add a snippet to change the order status. Add a filter to modify the admin columns. Add a hook to send a notification. Each one requires a developer, a staging environment, and a deployment. For something as simple as "show me which orders are from new customers", that's an absurd amount of overhead. You shouldn't need to write code to tell your store what to pay attention to.

Rules are just sentences

An OrderBadger rule is a plain English sentence that describes when a badge should appear. You type it into the rule builder, and the AI compiles it into logic that evaluates against every incoming order.

Here are real rules that work exactly as written:

- "Order total is over £200" - "Customer has placed 5 or more previous paid orders" - "At least one item in the order is on backorder" - "The order was placed on a weekend" - "Shipping is international and order total is over £100"

You don't need to know field names, operators, or data structures. You describe what you're looking for in the same language you'd use to explain it to a colleague.

Start simple, add conditions later

The best approach is to start with the simplest version of your rule and test it. If it matches too many orders, add a condition to narrow it down.

For example, start with "order total is over £500". Test it, see what it catches. If you're getting too many flags, refine it: "order total is over £500 and customer has 0 previous paid orders". Now you're only flagging high-value orders from new customers - the ones that actually need review.

You can always edit a rule later. Nothing is permanent. The Create and Test panel shows you exactly which test orders match and which don't, so you can validate before going live.

What you can reference in a rule

Rules can reference anything about the order, the customer, the products, the shipping, and the timing. Here are the main categories:

**Order details** - total price, subtotal, discount percentage, coupon count, total weight, number of items, number of distinct products, payment method

**Customer history** - previous order count, lifetime spend, average order value, days since last order, account age, whether it's a guest checkout, whether they're a reactivated dormant customer

**Product details** - categories, whether items are on backorder, on sale, virtual, stock levels after the order, per-item discount percentage, how many times the customer has bought each product before

**Shipping** - destination country, international or domestic, shipping zone, free shipping, remote area, shipping method

**Timing** - hour of day, day of week, business hours, peak season

You don't need to memorise these. Just describe what you want in plain English and the compiler will find the right fields.

Combining conditions

The real power comes from combining multiple conditions with "and". Each additional condition narrows the match, making your badge more targeted and useful.

Simple rules catch broad patterns: - "Customer is a guest checkout" - flags all guest orders

Compound rules catch specific situations: - "Customer is a guest checkout and order total is over £300 and the order was placed after 11pm" - flags suspicious late-night high-value guest orders

You can combine as many conditions as you need. OrderBadger handles the complexity of evaluating them all together - you just describe the scenario you're looking for.

A useful mental model: each condition is a filter. "Guest checkout" selects all guest orders. Adding "order total over £300" filters that set down to high-value guests. Adding "after 11pm" filters further to late-night high-value guests. Each "and" makes the net tighter.

Per-product conditions

Some rules need to check individual products rather than the order as a whole. OrderBadger handles this naturally:

- "At least one item is on backorder" - checks each product, badges the order if any match - "All items are in the same category" - checks every product, badges only if all match - "At least one item has a discount of more than 30%" - checks per-product discounts

You can combine per-product checks with order-level conditions: - "Customer has 3 or more previous orders and at least one item is from a category the customer has bought from 5 or more times" - this checks customer history at the order level and purchase patterns at the item level

The key phrases are "at least one item" (any product matches), "all items" (every product matches), and "two or more items" (a count of matching products).

Testing before going live

Every rule goes through the Create and Test flow before it can be activated. The test panel shows your rule evaluated against sample orders with clear pass/fail indicators.

If a test case fails when you expected it to pass, your rule might be too narrow. If it passes when you expected it to fail, your rule is too broad. Adjust the wording and re-test until the results match your expectations.

Once you're satisfied, activate the badge. It will evaluate against every new order automatically. You can deactivate, edit, or delete any badge at any time from the Inbox tab.

Try it: ready-made rule recipes

Each recipe below is a real rule template you can activate in OrderBadger. Click through for the full configuration, test fixtures, and customisation tips.

High Value Flag WooCommerce orders over a value threshold for review
Plain English rule “Order total is over £100”
order_150
Order total of £150 exceeds the £100 threshold.
order_100_01_boundary
Order total of £100.01 is just above the threshold.
See the full rule template →
Guest Flag orders placed without a customer account
Plain English rule “The order was placed as a guest without a customer account”
guest_order
Order was placed as a guest checkout without a customer account.
See the full rule template →
Backorder Flag orders containing backordered items
Plain English rule “At least one item in the order is on backorder”
one_item_backordered
The Gadget is on backorder while the Widget is in stock, so at least one item is backordered.
all_items_backordered
Every item in the order is on backorder, so the condition is met.
See the full rule template →

Try it in your store

OrderBadger is free on WordPress.org. Install it and create your first rule in minutes - no code required.

Install OrderBadger Free