Automatically Create Xero Invoices for Every New WooCommerce Order
When a new order is placed in WooCommerce, this workflow instantly creates a matching invoice in Xero — no manual data entry required. Store owners save time and keep their accounting records accurate and up to date.
- 1
Trigger on New WooCommerce Order
Add a
WooCommerce Triggernode. Set theEventfield toorder.created. In the node credentials, enter your WooCommerce store URL, consumer key, and consumer secret. n8n will register a webhook on your store automatically. This node fires every time a customer places a new order. - 2
Extract and Map Order Fields
Add a
Setnode connected to the trigger. Create fields namedcustomerName(mapped from{{$json.billing.first_name}} {{$json.billing.last_name}}),customerEmail(from{{$json.billing.email}}),orderTotal(from{{$json.total}}),orderId(from{{$json.id}}), andorderDate(from{{$json.date_created}}). This cleans up the data before sending it to Xero. - 3
Check Order Status is Valid
Add an
IFnode to make sure only paid or processing orders are sent to Xero. Set the condition to check that{{$json.status}}equalsprocessingORcompleted. Connect thetruebranch to the next Xero node. This prevents draft or cancelled orders from creating unwanted invoices. - 4
Create Invoice in Xero
Add an
HTTP Requestnode on thetruebranch of the IF node. SetMethodtoPOSTandURLtohttps://api.xero.com/api.xro/2.0/Invoices. SetAuthenticationtoOAuth2and configure your Xero OAuth2 credential. In theBodysection chooseJSONand paste a body that includesType: ACCREC,Contact.Name: {{$json.customerName}},Contact.EmailAddress: {{$json.customerEmail}},DueDate: {{$json.orderDate}},Status: DRAFT, and aLineItemsarray withDescription: WooCommerce Order #{{$json.orderId}},Quantity: 1, andUnitAmount: {{$json.orderTotal}}. Add the headerXero-tenant-idwith your Xero tenant ID.
Frequently asked questions
What Xero permissions do I need to set up the OAuth2 connection?
When connecting Xero via OAuth2 in n8n, make sure to grant the `accounting.transactions` scope so n8n can create invoices. You can set this in the n8n Xero OAuth2 credential settings under `Scope`.
Will this workflow create duplicate invoices if an order is updated?
The WooCommerce Trigger fires on `order.created` events only, not updates, so duplicates are unlikely. The IF node also filters out non-processing statuses for an extra layer of protection.
Can I add multiple line items from the order instead of one total line?
Yes, but it requires replacing the HTTP Request body with a more complex expression that loops over `$json.line_items` from the WooCommerce trigger output. For simplicity this recipe uses a single summary line item. A developer or an n8n Code node can handle the full line-item mapping.