SetGuestEmailOnCheckoutMutation
Description
Sets the guest email address on the cart. This mutation is a required step in the checkout process for guest users (non-logged-in customers) before placing an order.
Endpoint
mutation setGuestEmailOnCart($cartId: String!, $email: String!) {
setGuestEmailOnCart(cartId: $cartId, email: $email) {
# Return fields
}
}
Arguments
| Argument | Type | Required | Description |
|---|---|---|---|
| cartId | String | Yes | The unique identifier of the cart to set the email on. This ID is obtained from createGuestCart mutation. |
| String | Yes | The email address of the guest customer. This will be used for order confirmation and communication. |
Return Values
The mutation returns a CheckoutType object with the following field:
| Field | Type | Description |
|---|---|---|
| String | The email address that was set on the cart. |
Usage Example
mutation {
setGuestEmailOnCart(
cartId: "abc123",
email: "customer@example.com"
) {
email
}
}
Example Response
{
"data": {
"setGuestEmailOnCart": {
"email": "customer@example.com"
}
}
}
Notes
- This mutation is only required for guest checkouts. For logged-in customers, the email is automatically associated with the cart.
- The email address must be valid. If an invalid email is provided, an error will be thrown.
- This mutation must be called before attempting to place an order as a guest.
- The email address will be used for order confirmation and other communications related to the order.
- For guest users, this mutation should be called along with other checkout mutations like
setBillingAddressOnCheckout,setShippingAddressOnCheckout,setShippingMethodOnCheckout, andsetPaymentMethodOnCheckoutbefore placing an order.