E-commerce · n8n

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.

difficulty Intermediatesetup 45 minresult Every new WooCommerce order automatically generates a draft invoice in Xero with the customer name, email, line items, and order total.
  1. 1

    Trigger on New WooCommerce Order

    Add a WooCommerce Trigger node. Set the Event field to order.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. 2

    Extract and Map Order Fields

    Add a Set node connected to the trigger. Create fields named customerName (mapped from {{$json.billing.first_name}} {{$json.billing.last_name}}), customerEmail (from {{$json.billing.email}}), orderTotal (from {{$json.total}}), orderId (from {{$json.id}}), and orderDate (from {{$json.date_created}}). This cleans up the data before sending it to Xero.

  3. 3

    Check Order Status is Valid

    Add an IF node to make sure only paid or processing orders are sent to Xero. Set the condition to check that {{$json.status}} equals processing OR completed. Connect the true branch to the next Xero node. This prevents draft or cancelled orders from creating unwanted invoices.

  4. 4

    Create Invoice in Xero

    Add an HTTP Request node on the true branch of the IF node. Set Method to POST and URL to https://api.xero.com/api.xro/2.0/Invoices. Set Authentication to OAuth2 and configure your Xero OAuth2 credential. In the Body section choose JSON and paste a body that includes Type: ACCREC, Contact.Name: {{$json.customerName}}, Contact.EmailAddress: {{$json.customerEmail}}, DueDate: {{$json.orderDate}}, Status: DRAFT, and a LineItems array with Description: WooCommerce Order #{{$json.orderId}}, Quantity: 1, and UnitAmount: {{$json.orderTotal}}. Add the header Xero-tenant-id with 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.

About this recipe. Recipes on FlowRecipesHub are written for business owners, not developers, and are tested before publishing — how recipes get made. Some ingredient links are affiliate links that cost you nothing — full disclosure.