Is there an API to associate existing orders with a company location?

We are migrating to B2B set up from existing customer accounts.

After creating companies, company locations and associating the customers to the company locations.

Is there a way to associate existing customer orders with the company locations via API?

Thanks a lot!

We have looked into the B2B orders import but it creates new orders which is not what we want.

Hi Lishan,

If you’re using GraphQL, there are several methods to retrieve the Company Location for a specific order.

You can check under Orders > Purchasing Entity > Purchasing Company > Location.

I’ve attached a screenshot for reference:

If you’re new to the GraphQL explorer, it’s a great tool for experimenting with and exploring various GraphQL queries. You can access it here: Shopify GraphiQL Admin Explorer.

Best regards,

Robert

Hey Rober,

Thank you for your reply. Sorry that my question might have been confusing.

I am looking for an API that can add historical order to company locations. Do you know if there’s such a Graphql mutation to do so?

The customer accounts made purchases on the store before switching to to B2B, there are Graphql API for creating the companies, company locations, company contacts, is there API for add historical orders to company locations?

Thanks.

Thank you for the clarification, Lishan.

As far as I know, there’s currently no direct API option to include a customer’s order history when assigning them to a company. However, you can migrate the order history via the admin UI. You can find more details here: Migrating Customers - Shopify Help Center.

This migration feature was released in March 2024, so given that it’s relatively new, corresponding API support might be in the pipeline.

When adding a customer to a company, there’s an option to include order history:

Similarly, when removing a customer from a company, there’s an option to remove their order history: