Xero Contact ID and Woocomerce and creating an invoice

I want to create an invoice in Xero when a new order is created in Woocommerce, the contact has already been created in woocommerce.

I am struggling to config the Xero node. It requires the contact ID which I assume is the hidden contact ID xero assigns to each contact. But as the data is coming from Woocommerce how do I map to a contact ID that is not included in the data coming in from woocommerce?

If I use company and the contact ID as pulled from Woo, the same field used to create the contact in xero from woo using another n8n automaton I get the error

ERROR: Bad request - please check your parameters

JSON for post data was invalid,Error converting value “Dr. Mark Wertheimer” to type ‘System.Guid’. Path ‘Contact.ContactID’, line 1, position 61.

Please share the workflow

I had this exact issue.

I ended up exporting all the contacts and IDs to Google Sheets (using the Xero node), then doing a search on the contact column for the contact name.

The other way is; on your WP website, if you are using a form, have the form setup so that the end-user selects a contact that in the form has a value equal to the Xero Contact ID (I am using this for staff expense reports)

If you’re not using a form, you can use the Google Sheets method to find the ID based on the supplier/ customer and retrieve that ID to use in the Xero node.

Also, I believe there is a direct Xero plugin for Woo which be an alternative method:

1 Like

I wonder if it’s possible to do the google look up part using a script in a function node, or some other n8n node and remove the need to bring a google step into the mix. The plugin looks good but I am keen on solving this with n8n.

Found a solution using only n8n.

here is the work flow.

Basically, get all your Xero contacts and the new woorcommerce oder, merge them but keep only key matches, match on the company name. Be sure to make sure the company name in Xero and Woo are the same. That will return the correct Xero record complete with contact ID.

Then merge the results of the merge node with the woo trigger node to combine the details of the order with the now know contactID from xero. I simply appended the 2 inputs.

Then using the Xero node create an invoice and map the contactID field to the contactID. I could not find the contactID in the expression builder of the Xero node weirdly, although I could see it in the JSON. So I mapped iit to the out put of the 1st merge node where the contactID is first known.

Now to figure out how to mark a woocomm invoice as paid when reconning an invoice in Xero…

1 Like