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.

companyLocation ID for a specific B2B order

Solved

companyLocation ID for a specific B2B order

hepworthd
Tourist
7 1 2

We are looking to implement the new B2B site, however we are noticing the new company ID and companyLocation ID's are not being passed on the payload for the orders create webhook.  After some time looking through the graphQL orders query, we are unable to find how to get the companyLocation ID, was successful in getting the Company ID through companyContactProfiles/company.

 

Does anyone know how we can get the companyLocation ID either through the order graphQL query, or an alternative way through graphQL?

 

thanks.

Accepted Solution (1)

hepworthd
Tourist
7 1 2

This is an accepted solution.

Found the solution to find the companyLocationID for a specific order using GraphQL:

 

query MyQuery {
order(id: "gid://shopify/Order/%orderID%") {
id
name
poNumber
discountCode
customer {
companyContactProfiles {
company {
id
name
externalId
}
}
}
purchasingEntity {
... on PurchasingCompany {
__typename
location {
id
name
externalId
}
}
}
}
}

View solution in original post

Replies 4 (4)

Liam
Community Manager
3108 344 889

Hi Hepworthd,

 

The companyLocation object has a field for ID - can you use the company ID that you have retrieved from the order to make a call to the company object, which has a Company.locations connection and from there get the companyLocation ID?

 

 

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me 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

hepworthd
Tourist
7 1 2

I don't think this would work since we have many locations under a company.  The only solution I found was to re-call the order using the orders API, this then gives the company ID, and companyLocation ID.

hepworthd
Tourist
7 1 2

This is an accepted solution.

Found the solution to find the companyLocationID for a specific order using GraphQL:

 

query MyQuery {
order(id: "gid://shopify/Order/%orderID%") {
id
name
poNumber
discountCode
customer {
companyContactProfiles {
company {
id
name
externalId
}
}
}
purchasingEntity {
... on PurchasingCompany {
__typename
location {
id
name
externalId
}
}
}
}
}

Liam
Community Manager
3108 344 889

Glad you figured this out Hepworthd and thanks for coming back to post the answer!

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me 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