Back to Work Case Study · n8n Automation

AIEM Order Sync

A scheduled n8n automation that keeps AIEM's WooCommerce course orders mirrored to a live Google Sheet every 30 minutes — pending and completed orders refreshed automatically, no manual exports, no stale data.

n8n WooCommerce Google Sheets Automation Data Sync Education Tech No-code Scheduling
AIEM WooCommerce Order Export n8n workflow — Schedule Trigger fanning out to clear sheets, fetch WooCommerce orders, split by status, format, and write Pending/Completed tabs

About the Workflow

AIEM — the African Institute of Emergency Medicine — runs a medical training academy that sells courses through a WooCommerce-powered store. The admin team needed live visibility into pending and completed orders without manually exporting CSVs or logging into WordPress. The fix: a scheduled n8n automation that pushes data straight into the Google Sheet they already use every day.

Client

African Institute of Emergency Medicine (AIEM) — medical training academy selling continuing-education courses online to South African healthcare practitioners.

Platform

n8n (self-hosted), WooCommerce REST API, and Google Sheets. Africa/Johannesburg timezone, running on a 30-minute schedule.

Status

Live in production. Created January 2026, last updated April 2026. Continues to refresh order data 48 times a day without manual intervention.

Stale Data, Manual Exports

Administrators needed a single live view of course orders, broken out by status — but the existing workflow forced them back into the WordPress dashboard every time they needed an answer.

Manual CSV Exports

Every status check meant logging into WooCommerce, filtering by status, exporting, and dropping the file into a shared sheet by hand.

Data Always Lagging

By the time the spreadsheet was current, the WooCommerce store had moved on — pending orders had been paid, completed orders had been refunded.

WordPress Access for All

To see the same data, every team member needed WooCommerce admin credentials — a permissions surface AIEM didn't want to keep widening.

No Split by Status

The team wanted pending and completed orders in separate tabs — something the WooCommerce export flow didn't produce without extra work.

A Scheduled, Self-Refreshing Mirror

A scheduled n8n automation that runs every 30 minutes, clears both sheet tabs, and refreshes them with the latest order data — split cleanly into Pending and Completed, with one row per product per order.

  1. 01

    Clear Pending

    Wipes rows 2–500 on the Pending tab so old data can't bleed through into the next sync.

  2. 02

    Clear Completed

    Same operation on the Completed tab — both sheets start each run from a clean slate.

  3. 03

    Fetch Orders

    Pulls every WooCommerce order placed after 1 February 2026 via the REST API.

  4. 04

    Split by Status

    Two filter nodes route orders into two streams — one for status = pending, one for status = completed.

  5. 05

    Flatten Line Items

    A code node flattens nested order data into clean, spreadsheet-friendly rows — one row per product per order.

  6. 06

    Write & Dedupe

    Appends to each tab using append-or-update logic, matching on Order Number so duplicates never appear.

Workflow Architecture

A single trigger fans out into two parallel writes — same data shape, different status filter.

Schedule Trigger Fires every 30 minutes · Africa/Johannesburg
Clear sheet: Pending Removes rows 2–500 on the Pending tab
Clear sheet: Completed Removes rows 2–500 on the Completed tab
WooCommerce — Get Orders All orders after 2026-02-01 · returnAll
Status = Pending
Filter: Pending Keep orders with status = pending
Format Order Data Flatten line items into one row per product
Sheets — Pending Append/Update on Order Number
Status = Completed
Filter: Completed Keep orders with status = completed
Format Order Data Flatten line items into one row per product
Sheets — Completed Append/Update on Order Number

What's Under the Hood

Eight nodes, three services, one schedule. No webhook layer, no external orchestrator — n8n on its own.

Node Type Purpose
Schedule Trigger Trigger Fires every 30 minutes
Google Sheets ×2 Action Clears rows 2–500 on both tabs before refresh
WooCommerce Action Fetches all qualifying orders with date filter
Filter ×2 Logic Splits orders by status = pending / completed
Code ×2 Transform Flattens nested order + line_item data into a row per product
Google Sheets ×2 Action Writes formatted rows, matching on Order Number

What Each Row Looks Like

Every order is exploded into one row per purchased product, with the customer, billing, shipping, and item detail flattened side-by-side.

Order ID Order Number Order Status Order Date Order Total Currency Payment Method Customer ID Customer Email Customer Name Customer Phone Billing Address Billing City Billing State/Country Shipping Address Shipping City/State/Country Product ID Product Name Product SKU Quantity Item Price Item Subtotal Item Total Last Updated Processed By

Audit Findings & Trade-offs

Honest notes on the workflow as it stands — what's a deliberate trade-off, what's a small efficiency opportunity, and what's worth keeping an eye on as volumes grow.

Hardcoded row ceiling. The clear operation targets rows 2–500, which is a safe ceiling for now. If order volume ever exceeds 500 rows in a single sync, anything beyond row 500 wouldn't be cleared. Worth making rowsToDelete dynamic as the catalogue grows.

Annual date filter. The after: 2026-02-01 WooCommerce filter means only 2026 orders are fetched. This is intentional — but it should be bumped each January, or refactored into a config variable so it isn't a silent stale-data trap.

Duplicate formatter. The two Format Order Data code nodes are identical. They could be consolidated upstream of the filter split — minor efficiency win, not a bug.

No error branch. A failed WooCommerce API call would silently result in two blank sheets on the next run. Adding an error branch with a Slack or email notification would harden it against quiet failures.

returnAll on every run. The entire qualifying order set is fetched on each cycle. Fine for current volumes; at higher scale, pagination or an incremental "modified since" cursor would be the next step.

Timezone set correctly. Workflow runs on Africa/Johannesburg — order dates and sync timestamps line up with the team's working hours.

Got a Manual Process That's Eating Your Day?

If your team is exporting CSVs, copy-pasting between dashboards, or chasing data across three systems — there's almost certainly a small, sturdy automation that can take that off your plate. Let's talk.

Work like this sits under AI & Automation services — n8n workflow design, scheduled syncs, WooCommerce + Google Sheets integration, and structured data pipelines.

Related: see the AIEM Auto-Enrolment workflow running on the same n8n instance — WooCommerce purchases into LearnWorlds course access in under five minutes.