Getting Open Stores
When completing an order for Delivery or Collection you will need to find out what stores are available on the chosen day and what time-slots they have available.
This can be found via the getValidStores
query:
query getValidStores($merchantId: String!, $fulfillmentType: String!, $fulfillmentDate: String!, $address: String) {
getValidStores(merchantId: $merchantId, fulfillmentType: $fulfillmentType, fulfillmentDate: $fulfillmentDate, address: $address) {
stores {
id
name
address {
geom {
coordinates
}
}
fulfillmentTimeslots(fulfillmentDate: $fulfillmentDate, fulfillmentType: $fulfillmentType) {
startTime
endTime
value
}
slug
}
errors {
message
}
}
}
This will return 2 arrays:
1) errors: This contains messages for each closed / unavailable store as to why no slots are available
2) stores: This contains an object for each store containing the store name and ID and an array of each available timeslot for that store on the given date.
Sample variables:
{
"merchantId": "2ba090b2-d4dc-4fd1-ba5c-9e0b73586673", // Your merchant ID
"fulfillmentType": "pickup", // Order type 'pickup' or 'delivery'
"fulfillmentDate": "2022-07-01", // date in yyyy-mm-dd format
"address": "" // address if for delivery
}
Sample Response:
{
"data": {
"getValidStores": [
{
"errors": [],
"stores": [
{
"address": {
"geom": {
"coordinates": [
51.4824977,
-0.1450797
]
}
},
"fulfillmentTimeslots": [
{
"endTime": "10:45:00.000000",
"startTime": "10:30:00.000000",
"value": "2023-02-22T10:30:00.000000+00:00"
},
{
"endTime": "11:00:00.000000",
"startTime": "10:45:00.000000",
"value": "2023-02-22T10:45:00.000000+00:00"
},
{
"endTime": "11:15:00.000000",
"startTime": "11:00:00.000000",
"value": "2023-02-22T11:00:00.000000+00:00"
},
{
"endTime": "11:30:00.000000",
"startTime": "11:15:00.000000",
"value": "2023-02-22T11:15:00.000000+00:00"
},
{
"endTime": "11:45:00.000000",
"startTime": "11:30:00.000000",
"value": "2023-02-22T11:30:00.000000+00:00"
},
{
"endTime": "12:00:00.000000",
"startTime": "11:45:00.000000",
"value": "2023-02-22T11:45:00.000000+00:00"
},
{
"endTime": "12:15:00.000000",
"startTime": "12:00:00.000000",
"value": "2023-02-22T12:00:00.000000+00:00"
},
{
"endTime": "12:30:00.000000",
"startTime": "12:15:00.000000",
"value": "2023-02-22T12:15:00.000000+00:00"
},
{
"endTime": "12:45:00.000000",
"startTime": "12:30:00.000000",
"value": "2023-02-22T12:30:00.000000+00:00"
},
{
"endTime": "13:00:00.000000",
"startTime": "12:45:00.000000",
"value": "2023-02-22T12:45:00.000000+00:00"
},
{
"endTime": "13:15:00.000000",
"startTime": "13:00:00.000000",
"value": "2023-02-22T13:00:00.000000+00:00"
},
{
"endTime": "13:30:00.000000",
"startTime": "13:15:00.000000",
"value": "2023-02-22T13:15:00.000000+00:00"
},
{
"endTime": "13:45:00.000000",
"startTime": "13:30:00.000000",
"value": "2023-02-22T13:30:00.000000+00:00"
},
{
"endTime": "14:00:00.000000",
"startTime": "13:45:00.000000",
"value": "2023-02-22T13:45:00.000000+00:00"
},
{
"endTime": "14:15:00.000000",
"startTime": "14:00:00.000000",
"value": "2023-02-22T14:00:00.000000+00:00"
},
{
"endTime": "14:30:00.000000",
"startTime": "14:15:00.000000",
"value": "2023-02-22T14:15:00.000000+00:00"
},
{
"endTime": "14:45:00.000000",
"startTime": "14:30:00.000000",
"value": "2023-02-22T14:30:00.000000+00:00"
},
{
"endTime": "15:00:00.000000",
"startTime": "14:45:00.000000",
"value": "2023-02-22T14:45:00.000000+00:00"
},
{
"endTime": "15:15:00.000000",
"startTime": "15:00:00.000000",
"value": "2023-02-22T15:00:00.000000+00:00"
},
{
"endTime": "15:30:00.000000",
"startTime": "15:15:00.000000",
"value": "2023-02-22T15:15:00.000000+00:00"
},
{
"endTime": "15:45:00.000000",
"startTime": "15:30:00.000000",
"value": "2023-02-22T15:30:00.000000+00:00"
},
{
"endTime": "16:00:00.000000",
"startTime": "15:45:00.000000",
"value": "2023-02-22T15:45:00.000000+00:00"
},
{
"endTime": "16:15:00.000000",
"startTime": "16:00:00.000000",
"value": "2023-02-22T16:00:00.000000+00:00"
},
{
"endTime": "16:30:00.000000",
"startTime": "16:15:00.000000",
"value": "2023-02-22T16:15:00.000000+00:00"
},
{
"endTime": "16:45:00.000000",
"startTime": "16:30:00.000000",
"value": "2023-02-22T16:30:00.000000+00:00"
},
{
"endTime": "17:00:00.000000",
"startTime": "16:45:00.000000",
"value": "2023-02-22T16:45:00.000000+00:00"
},
{
"endTime": "17:15:00.000000",
"startTime": "17:00:00.000000",
"value": "2023-02-22T17:00:00.000000+00:00"
},
{
"endTime": "17:30:00.000000",
"startTime": "17:15:00.000000",
"value": "2023-02-22T17:15:00.000000+00:00"
},
{
"endTime": "17:45:00.000000",
"startTime": "17:30:00.000000",
"value": "2023-02-22T17:30:00.000000+00:00"
},
{
"endTime": "18:00:00.000000",
"startTime": "17:45:00.000000",
"value": "2023-02-22T17:45:00.000000+00:00"
},
{
"endTime": "18:15:00.000000",
"startTime": "18:00:00.000000",
"value": "2023-02-22T18:00:00.000000+00:00"
},
{
"endTime": "18:30:00.000000",
"startTime": "18:15:00.000000",
"value": "2023-02-22T18:15:00.000000+00:00"
},
{
"endTime": "18:45:00.000000",
"startTime": "18:30:00.000000",
"value": "2023-02-22T18:30:00.000000+00:00"
},
{
"endTime": "19:00:00.000000",
"startTime": "18:45:00.000000",
"value": "2023-02-22T18:45:00.000000+00:00"
},
{
"endTime": "19:15:00.000000",
"startTime": "19:00:00.000000",
"value": "2023-02-22T19:00:00.000000+00:00"
},
{
"endTime": "19:30:00.000000",
"startTime": "19:15:00.000000",
"value": "2023-02-22T19:15:00.000000+00:00"
},
{
"endTime": "19:45:00.000000",
"startTime": "19:30:00.000000",
"value": "2023-02-22T19:30:00.000000+00:00"
},
{
"endTime": "20:00:00.000000",
"startTime": "19:45:00.000000",
"value": "2023-02-22T19:45:00.000000+00:00"
},
{
"endTime": "20:15:00.000000",
"startTime": "20:00:00.000000",
"value": "2023-02-22T20:00:00.000000+00:00"
},
{
"endTime": "20:30:00.000000",
"startTime": "20:15:00.000000",
"value": "2023-02-22T20:15:00.000000+00:00"
},
{
"endTime": "20:45:00.000000",
"startTime": "20:30:00.000000",
"value": "2023-02-22T20:30:00.000000+00:00"
},
{
"endTime": "21:00:00.000000",
"startTime": "20:45:00.000000",
"value": "2023-02-22T20:45:00.000000+00:00"
}
],
"id": "060693ab-d541-4091-b124-03faae474979",
"name": "Coventry St",
"slug": "origincoffee-coventry-street"
}
]
}
]
}
}
Key Notes on getValidStores:
- Dates must always be passed in yyyy-mm-dd format
- If you pass a Store ID as a parameter you can also call getValidStores for a specific individual store, see below example:
query getValidStore($fulfillmentDate: String!, $fulfillmentType: String!, $storeId: String!, $address: String!) {
fulfillmentTimeslots(fulfillmentType: $fulfillmentType, fulfillmentDate: $fulfillmentDate, storeId: $storeId, address: $address) {
endTime
startTime
value
}
}
- You can pass either a
deliveryAddress
object or anaddress
string. We will match the closest store to the address geolocation. If adeliveryAddress
andaddress
are provided, then the deliveryAddress will take precedence.
query getValidStores($merchantId: String!, $fulfillmentType: String!, $fulfillmentDate: String!, $deliveryAddress: DeliveryAddressParams) {
getValidStores(merchantId: $merchantId, fulfillmentType: $fulfillmentType, fulfillmentDate: $fulfillmentDate, deliveryAddress: $deliveryAddress) {
stores {
id
name
address {
geom {
coordinates
}
}
fulfillmentTimeslots(fulfillmentDate: $fulfillmentDate, fulfillmentType: $fulfillmentType) {
startTime
endTime
value
}
slug
}
errors {
message
}
}
}
Sample variables:
{
"merchantId": "2ba090b2-d4dc-4fd1-ba5c-9e0b73586673", // Your merchant ID
"fulfillmentType": "delivery", // Order type 'pickup' or 'delivery'
"fulfillmentDate": "2022-07-01", // date in yyyy-mm-dd format
"deliveryAddress": {
"lineOne": "",
"lineTwo": "",
"city": "",
"zip": ""
}
}
Getting Valid Days
For Pre-Orders you may also want to see which days the merchant's stores are available. We can do this with the below query:
Query
query getAvailableDates($merchantId: uuid!, $fulfillmentType: String!, $startDate: String!, $endDate: String!, $lat: Float, $lng: Float) {
availableDays(merchantId: $merchantId, fulfillmentType: $fulfillmentType, startDate: $startDate, endDate: $endDate, lat: $lat, lng: $lng)
}
Sample variables
{
"merchantId": "5abb3b22-86b3-49e6-8774-a3ae185a525a",
"fulfillmentType": "delivery",
"startDate": "2022-06-22",
"endDate": "2022-06-30",
"lat": 51.5321074,
"lng": -0.0602542
}
Sample Response:
{
"data": {
"availableDays": [
"2022-07-22",
"2022-07-23",
"2022-07-24",
"2022-07-25",
"2022-07-26",
"2022-07-27",
"2022-07-28",
"2022-07-29",
"2022-07-30"
]
}
}
If there are no available dates then "availableDays" will be an empty array. Lat & lng are optional - supplying them will filter stores which are not able to deliver to the given co-ordinates.