Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

How to create a draft order for a specific company using APIs and its company ID?

Solved

How to create a draft order for a specific company using APIs and its company ID?

Thibaut-M
Shopify Partner
4 0 1

We're struggling to create a draft order associated with a company using APIs and a company ID.

 

Screenshot 2023-07-06 at 09.18.47.png

 

We found this documentation but we're struggling to retrieve the companyLocationId and companyContactId information. The only information we have is the Company ID.

 

How could we create draft orders for our testing company from API using only its Company ID?

Screenshot 2023-07-10 at 09.36.27.png

 

Thibaut
Accepted Solution (1)

ShopifyDevSup
Shopify Staff
1453 238 525

This is an accepted solution.

Hey @Thibaut-M - thanks for getting in touch. You should be able to pull this information through the company object in GraphQL directly, provided your app/integration has the read_customers scope and is being tested on a Plus Shop. Here's a quick example if you wanted to pull multiple companies and the relevant contact/location info:

{
 companies (first:10) {
   edges {
     node {
       id
       name
       contacts (first:10) {
         edges {
           node {
             id
           }
         }
       }
       locations (first:10) {
         edges {
           node {
             id
           }
         }
       }
     }
   }
 }
}
 

If you know the Shopify GID of the company you want to query, you would also be able to query the same fields, using the ID as an argument on the company object itself. Hope this helps!

 

Al | Shopify Developer Support 
 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Reply 1 (1)

ShopifyDevSup
Shopify Staff
1453 238 525

This is an accepted solution.

Hey @Thibaut-M - thanks for getting in touch. You should be able to pull this information through the company object in GraphQL directly, provided your app/integration has the read_customers scope and is being tested on a Plus Shop. Here's a quick example if you wanted to pull multiple companies and the relevant contact/location info:

{
 companies (first:10) {
   edges {
     node {
       id
       name
       contacts (first:10) {
         edges {
           node {
             id
           }
         }
       }
       locations (first:10) {
         edges {
           node {
             id
           }
         }
       }
     }
   }
 }
}
 

If you know the Shopify GID of the company you want to query, you would also be able to query the same fields, using the ID as an argument on the company object itself. Hope this helps!

 

Al | Shopify Developer Support 
 

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog