Cart object is the fundamental building block for checking out with Rye. Carts hold productscreateCart mutation.1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253mutation CreateFirstCart { createCart( input: { items: { amazonCartItemsInput: [{ quantity: 1 productId: "B00A2KD8NY" }] } } ) { cart { id # NOTE: This `id` is important! cost { isEstimated subtotal { currency displayValue value } shipping { currency displayValue value } total { currency displayValue value } } stores { ... on AmazonStore { cartLines { quantity product { id title } } errors { code message } } } } errors { code message } } }
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.AmazonStoreError or ShopifyStoreError). A robust integration with Rye should check both levels of the response, and handle errors if they exist.1234567891011121314151617181920212223242526272829303132333435363738mutation AddCeraVeCream { addCartItems( input: { # NOTE: Replace this value with your own cart's identifier! id: "TgDZ0GvuqZkVlmdhm94f" items: { amazonCartItemsInput: [{ quantity: 2 productId: "B08CQDF382" }] } } ) { cart { id # `cost` omitted for brevity stores { ... on AmazonStore { cartLines { quantity product { id title } } errors { code message } } } } errors { code message } } }
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.