The general recommended sequence for using ECS cart operations is:
Identify a specific product that the user wishes to purchase and locate a vendor offering that product for sale. To do this you must use an operation that supports the Offers or OfferFull response group (i.e., ItemLookup, ItemSearch, ListLookup, or SimilarityLookup) to obtain the availability and price(s) of a product.
If there is no existing cart, then you must create a cart with the first item(s) that the customer has selected. The CartCreate operation returns a CartId and HMAC that will must be used for future operations on that cart. Note that you can only create a cart once you have an item to add to that cart (you cannot create an empty cart). Store the CartId and HMAC of the new cart in a way that allows you to link the cart to the current customer.
If the customer has an existing cart that they have not yet purchased, you may need to refresh their cart with a CartGet operation request, specifying the CartId and HMAC that were returned when the cart was created.
Allow the customer to browse/shop.
For each item that the customer wishes to purchase, you must locate a vendor and display their price/availability; once the item has been selected, you must add it to the cart with its ASIN (Amazon) or OfferListingId (non-Amazon vendors) using the CartAdd operation. To add to an existing cart, you must specify the CartId/HMAC of the existing cart.
If the customer wishes to change quantities or delete an item (i.e., set the quantity to zero), use the CartModify operation, and provide the CartItemId for the item entry to be modified or deleted. To modify an existing cart, you must also specify its CartId/HMAC.
If the customer wishes to save an item for later purchase, you can use the CartModify operation, specifying the CartId/HMAC of the existing cart.
If the customer wishes to delete all of their cart items, use the CartClear operation, specifying the CartId/HMAC of the existing cart. Note that this removes both cart items and saved items.
Process the Purchase button by transferring the customer to Amazon's Web site via the purchase URL that was returned with the latest cart operation. This URL includes your Associate ID (to ensure correct credits for commissions) as well as encoded versions of the CartId and HMAC for the customer's cart.
Discard the CartId and HMAC and update your customer's record to indicate that future visits will start a new shopping session with a new cart.