The CartClear operation enables you to remove all of the items in a remote shopping cart, including SavedForLater items. To remove only some of the items in a cart or to reduce the quantity of one or more items, use
CartModify
.
To delete all of the items from a remote shopping cart, you must specify the cart using the CartId and HMAC values, which are returned by the CartCreate operation. A value similar to the HMAC, URLEncodedHMAC, is also returned. This value is the URL encoded version of the HMAC. This encoding is necessary because some characters, such as + and /, cannot be included in a URL. Rather than encoding the HMAC yourself, use the URLEncodedHMAC value for the HMAC parameter.
CartClear does not work after the customer has used the PurchaseURL to either purchase the items or merge them with the items in their Amazon cart.
Carts exist even though they have been emptied. The lifespan of a cart is 7 days since the last time it was acted upon. For example, if a cart created 6 days ago is modified, the cart lifespan is reset to 7 days.
The following table describes the request parameters for CartClear. Parameter names are case sensitive.
| Parameter | Definition | Req'd? | Valid Values |
|---|---|---|---|
AssociateTag
| Alphanumeric token that uniquely identifies an Associate. This value is required only if the cart was created using the AssociateTag. | Depends | Valid AssociateTag that was used in the related CartCreate request. |
CartId
| Alphanumeric token returned by CartCreate that identifies a cart. | Yes | Value returned by CartCreate. |
HMAC
| Hash Message Authentication Code returned by CartCreate that identifies a cart. This is an encrypted alphanumeric token that is used to authenticate cart operations. | Yes | Value returned by CartCreate. |
MergeCart
| A boolean value that when True specifies that the items in a customer's remote shopping cart are added to the customer’s Amazon retail shopping cart. This occurs when the customer elects to purchase the items in their remote shopping cart. When the value is False (the default) the remote shopping cart contents are not added to the retail shopping cart. Instead, the customer is sent directly to the Order Pipeline when they elect to purchase the items in their cart. This parameter is valid only in the US locale. In all other locales, the value is always False. | No |
False (Default) True (Invalid in non-US locales) |
ResponseGroup
| Specifies the types of values to return. You can specify multiple response groups in one request by separating them with commas. | No |
Cart (Default) Request (Default) |
CartClear also accepts the parameters that all operations can use. For more information, see, Common Request Parameters.
The following table describes the default response tags included in CartClear responses.
| Element Tag | Definition |
|---|---|
Cart
| Container for remote shopping cart related response elements. |
| Container for CartClear and HMAC. |
CartId
| Alphanumeric token returned by CartCreate that uniquely identifies a cart. |
HMAC
| Hash Message Authentication Code returned by CartCreate that identifies a cart. This is an encrypted alphanumeric token that is used to authenticate cart operations. |
URLEncodedHMAC
| URL encoded version of the HMAC. This encoding is necessary because some characters, such as + and /, cannot be included in a URL. |
For more information about the parent elements of these tags, see the appropriate response group in Response Groups
Use CartClear in the following ways:
Remove all items from a specified cart:
http://ecs.amazonaws.com/onca/xml? Service=AWSECommerceService& AWSAccessKeyId=[Access Key ID]& AssociateTag=[Associate Tag]& Operation=CartClear& CartId=[Cart ID]& HMAC=[URL-encoded HMAC]
This operation removes all of the items in the specified cart. Because the HMAC includes the AssociateTag, if you created the cart using AssociateTag, you must supply it in this request.
The response to this request is shown in, Response to Sample Request, below.
The following XML is a snippet of the full response to the first sample request above.
<Cart>
<Request>
<IsValid>True</IsValid>
<CartClearRequest>
<CartId>102-2689399-8023324</CartId>
<HMAC>iLYO/W0hft0Te4uXAbMiBhs36T8=</HMAC>
</CartClearRequest>
</Request>
<CartId>102-2689399-8023324</CartId>
<HMAC>iLYO/W0hft0Te4uXAbMiBhs36T8=</HMAC>
<URLEncodedHMAC>iLYO/W0hft0Te4uXAbMiBhs36T8=</URLEncodedHMAC>
</Cart>