Solved

Unable to associate new orders with the correct customer using API; new customer created instead

yuwen
Shopify Partner
8 1 0

Hi everyone,

I'm helping a client migrate data to Shopify using the Admin API. I need to create historical orders, but I've noticed that after creating each order, the Shopify admin backstage generates a new customer entry, even if the profile for that customer already exists with the same email. The backstage ends up showing two customer profiles with the same name and email.

I have tried including the pre-built customer's email in the order.customer.email and order.email parameters, but it doesn't work. The orders cannot be associated with the same customer. I would like to know if this behavior is intended by design or if there are additional parameters I should include to correctly associate the "new" order (new to Shopify, but historical for my client) with the customer profile.
Any help is greatly appreciated. Thank you!

Accepted Solution (1)

yuwen
Shopify Partner
8 1 0

This is an accepted solution.

I solved this by attaching a customer id in the order:  order.customer.id. So I modified the process as follows: 

- get customer Id with Email by calling customer API

- attach this Id in the order

- create order by calling order API

 

View solution in original post

Reply 1 (1)

yuwen
Shopify Partner
8 1 0

This is an accepted solution.

I solved this by attaching a customer id in the order:  order.customer.id. So I modified the process as follows: 

- get customer Id with Email by calling customer API

- attach this Id in the order

- create order by calling order API