Solved

companyLocation ID for a specific B2B order

hepworthd
Tourist
6 1 1

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
6 1 1

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
Shopify Staff
2731 292 743

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
6 1 1

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
6 1 1

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
Shopify Staff
2731 292 743

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