How to Export WooCommerce Orders to JSON
Export WooCommerce orders (or products and customers) to a JSON file every night through the WooCommerce REST API, and deliver it to your File Store, an SFTP server or another system's endpoint.
What This Integration Does
WooCommerce's built-in export produces CSV, and JSON export plugins add load to your WordPress server and need maintaining. This Spojit workflow reads orders through the WooCommerce REST API instead, pages through every result, keeps the fields the receiving system needs, and writes them as one JSON file per run. Typical uses are feeding a 3PL or ERP that accepts JSON files, giving a data team a daily extract, and keeping an off-site backup of order data.
Each run exports orders modified since the previous run (with a small overlap), writes a new dated file, and changes nothing in WooCommerce, so you can re-run any night safely. Because the export reads modified orders rather than only new ones, status changes such as refunds and completions appear in the next file.
Prerequisites
- A WooCommerce connection with a read-only REST API key.
- Optional: an FTP / SFTP connection, or the URL and credentials of the system that will receive the JSON.
Step 1: Schedule Trigger
Add a Trigger node with type Schedule and cron 30 1 * * *. Add a Date & Time subtract step named since that takes 25 hours (one day plus an hour of overlap) off the trigger time; its ISO 8601 result is in {{ since.iso }}.
Step 2: Read Modified Orders
Add a Connector node on WooCommerce in Direct Mode with raw-api-request, which lets you filter on modification date:
method:GETpath:/orders?modified_after={{ since.iso }}&per_page=100&page={{ page }}&orderby=modified&order=asc
For new orders only, the simpler list-orders tool with after works too. Name the output batch.
Step 3: Page Through Every Order
Wrap Step 2 in a Loop in While mode. Start page at 1 and repeat while the last batch returned 100 orders, increasing page each time, and collect the orders into one list. WooCommerce allows at most 100 records per page.
Step 4: Shape Each Order
Add a Transform with Iterate over set to the collected orders and keep what the consumer needs:
{
"id": {{ item.id }},
"number": "{{ item.number }}",
"status": "{{ item.status }}",
"created_gmt": "{{ item.date_created_gmt }}",
"modified_gmt": "{{ item.date_modified_gmt }}",
"currency": "{{ item.currency }}",
"total": "{{ item.total }}",
"customer": { "email": "{{ item.billing.email }}", "name": "{{ item.billing.first_name }} {{ item.billing.last_name }}" },
"shipping": {{ item.shipping }},
"lines": {{ item.line_items }}
}
Keep money values as strings if the receiving system is an accounting tool (WooCommerce sends them as exact decimal strings); convert them to numbers only for analytics.
Step 5: Write and Deliver the File
Add JSON Tools stringify, then a File Store node with Save a file named woocommerce-orders-{{ run_date.result }}.json and content type application/json. Deliver it with one of:
- FTP / SFTP
upload-fileto the partner's inbound folder. - HTTP Requests
http-postto the receiving system's API, with the list as the body.
Tips
- Products and customers: the same pattern works with
/products?modified_after=...and/customers?modified_after=..., or thelist-productsandlist-customerstools. - Order meta: plugin data such as delivery dates and gift messages is in
meta_data. Pick the keys you need in the Transform rather than exporting every meta entry. - Write a done file: some systems want a marker file after the data file. Upload an empty
.donefile after the JSON so the consumer never reads a half-written export. - Live JSON feed: to let a system pull current orders on demand, use a Webhook trigger in Sync mode and return the list from a Response node.
Common Pitfalls
- REST API blocked by security plugins: some hosts and plugins block
/wp-json/. A 401 or 403 with a valid key usually means the REST API is blocked for that user. - Timezone confusion:
modified_afteris interpreted in the site's timezone unless you passdates_are_gmt=true. Add it whensinceis in UTC. - Personal data: order exports include names, emails and addresses. Share only what the receiving party needs and use SFTP rather than email.
- Large stores and timeouts: very large first exports can be slow on shared hosting. Backfill in monthly chunks by running the workflow manually with a fixed window.
Testing
Run the workflow manually with a two-hour window, open the saved file and compare the order numbers with WooCommerce -> Orders filtered to the same period. Then send a sample to the receiving system before turning the schedule on.