Carts
A cart is basically a basket that customers put items into that they want to purchase. While Cortex API’s shopping cart has this as its core functionality, there is much more to this shopping cart than just that.
Key concepts developers should know about carts:
A default cart is always available, registered users can create additional carts
You can empty a cart’s contents
All carts except the default cart can be deleted
You do not need to create an order for the cart, an order is always available
Cortex automatically persists carts between customer sessions so a customer can log on through a mobile phone and then log on through another device to complete the purchase
A cart’s line items is a collection of items that have been added to a cart. A line item can have one or more of the same items in it. For example, one line item can have seven Rocker T-Shirt or a single Rocker T-Shirt, but it won’t have one Rocker T-Shirt and a song track. The song track and T-shirt would be in separate line items.
Read Default Cart
Retrieve the shopper’s default cart. When using default in the cart’s URI, default evaluates to the logged in shopper’s cart I.D. See the main Cortex documentation for more information on default.
Workflow
- Start with root
GET
the link with rel: defaultcart- Render the response
Response Fields
carts.cart
Type: Name | Description | Type |
---|---|---|
total-quantity | Lists the total number of items in the cart. | integer |
Read Carts List
Retrieve the list of carts that belong to a shopper.
Workflow
- Start with root
GET
the link with rel: carts- Render the response
Read Cart Descriptor
Retrieve the descriptor that describes a shopping cart.
Workflow
- Start with carts
GET
the link with rel: elementGET
the link with rel: descriptor- Render the response
Create Cart
Retrieve and submit the form to create new carts.
Workflow
- Start with carts
GET
the link with rel: createcartform- Fill out the form
POST
the form using the link with rel: createcartaction
Request Fields
carts.create-cart-form-entity
Type: Name | Description | Type |
---|---|---|
descriptor | The description of the cart. | object |
Add Item To Default Cart
Add an item to the user’s default cart. The add to cart form may have some blocking advisors.
The add to cart form can contain message IDs, such as item.missing.price
, item.insufficient.inventory
, or item.not.in.store.catalog
.
For more information, see Structured Messages and Advisors.
Workflow
- Start with item
GET
the link with rel: addtocartform- Fill out the form
POST
the form using the link with rel: addtodefaultcartaction
Request Fields
carts.line-item
Type: Name | Description | Type |
---|---|---|
quantity | The total number of items in the line item. | integer |
configuration | The details of the line item configuration. | object |
Add Item To Specific Cart
Add an item to one of the user’s carts. The add item to specific cart form may have some blocking advisors.
The add to cart form can contain message IDs, such as item.missing.price
, item.insufficient.inventory
, or item.not.in.store.catalog
.
For more information, see Structured Messages and Advisors.
Workflow
- Start with item
GET
the link with rel: addtocartformsGET
the link with rel: element- Fill out the form
POST
the form using the link with rel: addtocartaction
Request Fields
carts.line-item
Type: Name | Description | Type |
---|---|---|
quantity | The total number of items in the line item. | integer |
configuration | The details of the line item configuration. | object |
Read Add Items To Cart Form
Retrieve the add items to cart form on the cart. This form has a warning message when the cart already has items in it.
For more information, see cart.is.not.empty
in the Structured Messages topic.
Workflow
- Start with cart
GET
the link with rel: additemstocartform- Render the response
Response Fields
carts.add-items-to-cart-form
Type: Name | Description | Type |
---|---|---|
items | The items. | array |
code | The sku code of the item to add to cart. | string |
quantity | The total number of items to add to cart. | integer |
Add Items To Cart
Add multiple items to the cart.
Workflow
- Start with add-items-to-cart-form
- Fill out the form
POST
the form using the link with rel: additemstocartaction
Request Fields
carts.add-items-to-cart-form
Type: Name | Description | Type |
---|---|---|
items | The items. | array |
code | The sku code of the item to add to cart. | string |
quantity | The total number of items to add to cart. | integer |
Read Cart Memberships
Retrieves the list of carts that an item has been added to. The list is empty if the item is not added to a cart.
Workflow
- Start with item
GET
the link with rel: cartmemberships- Render the response
Read Line Item
Retrieve a single line item from a shopper’s cart.
Workflow
- Start with cart
GET
the link with rel: lineitemsGET
the link with rel: element- Render the response
Response Fields
carts.line-item
Type: Name | Description | Type |
---|---|---|
quantity | The total number of items in the line item. | integer |
configuration | The details of the line item configuration. | object |
Update Line Item
Update the number of items in a line item. For example, if you have 4 Rockstar T-Shirts in a line item, you can use this method to remove 3 of the t-shirts and leave 1 T-shirt in the cart.
Workflow
- Start with line-item
- Edit the line-item object with new details
- Update line-item using a
PUT
request
Delete Line Item
Delete a line item from the cart.
Workflow
- Start with line-item
DELETE
line-item
Empty Cart
Remove all line items from the cart.
Workflow
- Start with cart
GET
the link with rel: lineitemsDELETE
line-items
Read Line Item Cart
Retrieve the cart that has the given line item. This workflow is useful when you need to determine which cart the line item belongs to.
Workflow
- Start with line-item
GET
the link with rel: cart- Render the response
Response Fields
carts.cart
Type: Name | Description | Type |
---|---|---|
total-quantity | Lists the total number of items in the cart. | integer |