Fetch customer addresses
Retrieve all delivery addresses for a company, useful for the address book and checkout address selector.
Query
query GetCompanyAddresses($companyId: Float!, $type: AddressType) {
addressesByCompanyId(companyId: $companyId, type: $type) {
id
firstName
lastName
company
street
number
numberExtension
postalCode
city
country
isDefault
type
name
phone
email
}
}
Variables
{
"companyId": 141,
"type": "delivery"
}
Response
{
"data": {
"addressesByCompanyId": [
{
"id": 81166,
"firstName": "Thomas",
"lastName": "Visser",
"company": "Brouwer Industrie",
"street": "Keizersgracht",
"number": "452",
"numberExtension": null,
"postalCode": "1016 GE",
"city": "Amsterdam",
"country": "NL",
"isDefault": "N",
"type": "delivery",
"name": "",
"phone": null,
"email": null
},
{
"id": 82101,
"firstName": "Noor",
"lastName": "Smit",
"company": "Brouwer Industrie",
"street": "Herengracht",
"number": "100",
"numberExtension": null,
"postalCode": "1015 BS",
"city": "Amsterdam",
"country": "NL",
"isDefault": "Y",
"type": "delivery",
"name": "",
"phone": null,
"email": null
}
]
}
}
How it works
Pass the companyId from the logged-in user's profile. The optional type argument filters by address type: use delivery or invoice. Omit it to get all addresses. The isDefault field indicates which address should be pre-selected in the checkout. The id field can be used to populate the cart address via cartUpdateAddress. There is also addressesByCustomerId for B2C customers.