Is there a mutation for adding a customer's orders via GraphQL?

I’m seeing this checkbox when adding a customer that has existing orders to a company manually. I want to add this feature to our B2B app but I’m struggling to find anything in the docs.

Anyone have eyes on that? Is that checkbox hooking into an internal API?

1 Like

Hi @Jivan

That checkbox in the admin for associating a customer’s existing orders with a company when adding them as a contact is an internal admin feature. Unfortunately, there’s no public API mutation that replicates that behavior for existing orders.

The orderUpdate mutation doesn’t support setting a companyLocationId or purchasingEntity, so you can’t retroactively associate an already-created order with a company through the API.

What is available for B2B orders via the API:

  • Importing historical orders: The orderCreate mutation accepts a companyLocationId field, so you can create orders that are associated with a company from the start. The customer must already have a role assignment to that company location.
  • Creating B2B draft orders: The draftOrderCreate mutation supports a purchasingEntity input where you can specify the companyId, companyLocationId, and companyContactId.

Thanks for confirming @Liam-Shopify! I figured this was internal-only or something. Any chance for us to request access?

The problem some of our merchants are having is that when they use our app to approve a new company, the company contact might have orders but they don’t get synced to the assigned company location. This adds more work for them to have to go back through and manually add them so that the company location has the proper order history.

1 Like