Create a cart, and make adjustments to cart items in response to shopper requests.
Cart
object is the fundamental building block for checking out with Rye. Carts hold products
Some key terms to understand when working with carts are:
createCart
mutation.
The GraphQL operation below will create a cart containing an egg separator sold by Amazon:
id
field returned under the cart
object is very important. It is the identifier for the cart you created, and you must have it available if you want to use other cart management endpoints on this cart. In the next step, we’ll look at how we can use this cart identifier with the addCartItems
mutation to add a second product.
795
should therefore be interpreted as “795 cents” when working with USD. We report currencies in this way in order to avoid floating point arithmetic errors.
Note that it is possible for there to be top-level errors for the cart itself, and also for there to be more granular errors on the stores the cart relates to (in the form of AmazonStoreError
or ShopifyStoreError
). A robust integration with Rye should check both levels of the response, and handle errors if they exist.
addCartItems
, you may want to look at the documentation for the following API operations as well:
deleteCartItems
: Used for removing cart items from the cart.updateCartItems
: Used for updating the quantity of cart items. For instance, to support the user adding a third unit of cleanser to their cart.shipping
price available. This is because when we created our cart, we didn’t tell it where we we’d like to ship the cart items to. We can fix this by attaching a buyer identity to our cart, which we will do in the next section.