setGuestEmailOnCart mutation
For guest customers, you must assign an email to the cart before you place the order.
A logged-in customer specifies an email address when they create an account. Therefore, you can place the order without explicitly setting the email.
Syntax
mutation: {setGuestEmailOnCart(input: SetGuestEmailOnCartInput): {SetGuestEmailOnCartOutput}}
Reference
The setGuestEmailOnCart reference provides detailed information about the types and fields defined in this mutation.
Example usage
Request:
mutation {
setGuestEmailOnCart(
input: {
cart_id: "4JQaNVJokOpFxrykGVvYrjhiNv9qt31C"
email: "jdoe@example.com"
}
) {
cart {
email
}
}
}
Response:
{
"data": {
"setGuestEmailOnCart": {
"cart": {
"email": "jdoe@example.com"
}
}
}
}
Errors
Error
Description
Could not find a cart with ID "XXX"The ID specified in the
cart argument does not exist.Invalid email formatThe value specified in the
email argument has an incorrect format.Required parameter "cart_id" is missingThe
cart_id argument was omitted or contains an empty value.Required parameter "email" is missingThe
email argument was omitted or contains an empty value.The current user cannot perform operations on cart "XXX"An unauthorized user (guest) tried to set the email address on the customer's cart.
The request is not allowed for logged in customersAn authorized user (customer) is not allowed to use the
setGuestEmailOnCart mutation.