Validating a Cart
Why Validate
Before checking out we need to validate that the users purchase is still valid.
- The store is still open
- The timeslot requested is still available
ValidateCart query
We do this with the ValidateCart query:
query ValidateCart($cartId: ID!) {
ValidateCart(cartId: $cartId) {
nextAvailable {
datetime
range
value
}
valid
isStoreOpen
discountErrors
discountWarnings
}
}
variables:
{
"cartId": "f59822a7-b30f-4047-a028-125a8956366c"
}
Failures and Warnings
Failures
If valid
is false
or isStoreOpen
is false
the cart should not be allowed to proceed.
nextAvailable
will give the next available date and time for this store which can be offered to the user.
discountErrors
will detail any errors that will prevent you from checking out.
Warnings
discountWarnings
will return an array of warnings. These will not be enforced until you try to make a payment.