Skip to main content

Linking A cart to a user

Logged in user

When creating a cart with a logged in user simply pass the user ID as a variable in createSlerpCart or editSlerpCart to associate the cart with a user.

Guest Checkout

If a user is checking out as a guest, you will need to add some details to a cart before they can check out successfully:

To do this use the below mutation after the cart has been created:

mutation UpdateCustomerDetails($cartId: ID!, $customerDetails: CustomerDetailsParams!, $recipientDetails: RecipientDetailsParams, $orderNotes: String) {
updateCartCustomerDetails(
cartId: $cartId
customerDetails: $customerDetails
recipientDetails: $recipientDetails
orderNotes: $orderNotes
) {
id
}
}

Example variables:

{
"cartId": "4fe810ed-db3c-4055-b61d-ecb567dc7196",
"customerDetails": {
"first_name": "test",
"last_name": "uset",
"email": "[email protected]",
"contactNum": "07777777777"
},
"recipientDetails": {
"first_name": "test",
"last_name": "uset",
"contactNum": "07777777777"
},
"orderNotes": "this is a note"
}

Some notes on fields:

  • receipientDetails can be different from customerDetails if order is for a gift
  • orderNotes are optional

Validation errors will be returned in the following format:

{
"data": {
"updateCartCustomerDetails": null
},
"errors": [
{
"message": "Phone number is required",
"path": ["updateCartCustomerDetails"],
"variablePath": ["contact_num"]
},
{
"message": "Email is required",
"path": ["updateCartCustomerDetails"],
"variablePath": ["email"]
}
]
}

Adding delivery notes and gifting

If you want to allow your customers to add custom delivery notes or gift notes you will need to run this mutation to apply them:

mutation UpdateCart($cartId: uuid!, $dropoff_notes: String, $gift_wrapped: Boolean, $gift_wrap_message: String) {
update_carts_by_pk(
pk_columns: {id: $cartId}
_set: {dropoff_notes: $dropoff_notes, gift_wrapped: $gift_wrapped, gift_wrap_message: $gift_wrap_message}
) {
dropoff_notes
gift_wrapped
gift_wrap_message
}
}

Variables:

{
"cartId": "a063e601-382c-4f9c-8460-05720b81429f",
"dropoff_notes": "example delivery instructions",
"gift_wrap_message": "test gift note",
"gift_wrapped": true
}

Obviously this is optional and not required if none of the above fields are needed.