Saving Customer Address
NOTE: These mutations and queries will only work when used with a valid customer ID and apiKey which should be received during user authentication.
Customers can have addresses saved to their record, this allows for faster checkout times in future.
Saving a customer address:
mutation CreateAddress($customerId: ID!, $flatNumber: String, $line1: String, $line2: String!, $zip: String!, $country: String!, $city: String!, $defaultBillingAddress: Boolean, $defaultShippingAddress: Boolean, $label: String) {
createAddress(
customer_id: $customerId
flatNumber: $flatNumber
line_1: $line1
line_2: $line2
zip: $zip
country: $country
city: $city
defaultBillingAddress: $defaultBillingAddress
defaultShippingAddress: $defaultShippingAddress
label: $label
) {
id
}
}
Variable example:
{
"label": "EG: Work, Home",
"city": "London",
"zip": "EC2A 3QT",
"defaultShippingAddress": true, // This allows you to use it as defauly later.
"country": "UK",
"customerId": "8779f643-f30e-4d10-8f15-76a10413464f",
"line1": "Charlotte Road 57"
}
Accessing saved address:
query GetCustomer($customerId: uuid!) {
customers_by_pk(id: $customerId) {
salutation
first_name
last_name
addresses {
id
line_1
line_2
city
country
zip
contact_num
default_shipping_address
default_billing_address
flat_number
label
}
}
}