Skip to main content
Version: 8.3.x

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​

  1. Start with root
  2. GET the link with rel: defaultcart
  3. Render the response

Response Fields​

Type: carts.cart​

NameDescriptionType
total-quantityLists the total number of items in the cart.integer

Read Carts List​

Retrieve the list of carts that belong to a shopper.

Workflow​

  1. Start with root
  2. GET the link with rel: carts
  3. Render the response

Read Cart Descriptor​

Retrieve the descriptor that describes a shopping cart.

Workflow​

  1. Start with carts
  2. GET the link with rel: element
  3. GET the link with rel: descriptor
  4. Render the response

Create Cart​

Retrieve and submit the form to create new carts.

Workflow​

  1. Start with carts
  2. GET the link with rel: createcartform
  3. Fill out the form
  4. POST the form using the link with rel: createcartaction

Request Fields​

Type: carts.create-cart-form-entity​

NameDescriptionType
descriptorThe 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​

  1. Start with item
  2. GET the link with rel: addtocartform
  3. Fill out the form
  4. POST the form using the link with rel: addtodefaultcartaction

Request Fields​

Type: carts.line-item​

NameDescriptionType
quantityThe total number of items in the line item.integer
configurationThe 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​

  1. Start with item
  2. GET the link with rel: addtocartforms
  3. GET the link with rel: element
  4. Fill out the form
  5. POST the form using the link with rel: addtocartaction

Request Fields​

Type: carts.line-item​

NameDescriptionType
quantityThe total number of items in the line item.integer
configurationThe details of the line item configuration.object

Read Add Items To Cart Form​

Retrieve the add items to cart form on the cart.

Workflow​

  1. Start with cart
  2. GET the link with rel: additemstocartform
  3. Render the response

Response Fields​

Type: carts.add-items-to-cart-form​

NameDescriptionType
itemsThe items.array
  codeThe sku code of the item to add to cart.string
  quantityThe total number of items to add to cart.integer
  configurationThe details of the line item configuration.object

Add Items To Cart​

Add multiple items to the cart.

Workflow​

  1. Start with add-items-to-cart-form
  2. Fill out the form
  3. POST the form using the link with rel: additemstocartaction

Request Fields​

Type: carts.add-items-to-cart-form​

NameDescriptionType
itemsThe items.array
  codeThe sku code of the item to add to cart.string
  quantityThe total number of items to add to cart.integer
  configurationThe details of the line item configuration.object

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​

  1. Start with item
  2. GET the link with rel: cartmemberships
  3. Render the response

Read Cart Line Items​

Retrieve a list of cart line items.

Workflow​

  1. Start with cart
  2. GET the link with rel: lineitems
  3. Render the response

Read Paginated Cart Line Items​

Retrieve a list of paginated cart line items.

Workflow​

  1. Start with cart
  2. GET the link with rel: paginatedlineitems
  3. Render the response

Read Cart Line Items Paginator​

Retrieve a paginator form to configure line items pagination.

Workflow​

  1. Start with paginated-line-items
  2. GET the link with rel: paginator
  3. Render the response

Response Fields​

Type: carts.cart-line-item-paginator​

NameDescriptionType
sizePage size. Number of line items on a page.integer

Read Line Item​

Retrieve a single line item from a shopper’s cart.

Workflow​

  1. Start with cart
  2. GET the link with rel: lineitems
  3. GET the link with rel: element
  4. Render the response

Response Fields​

Type: carts.line-item​

NameDescriptionType
quantityThe total number of items in the line item.integer
configurationThe 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​

  1. Start with line-item
  2. Edit the line-item object with new details
  3. Update line-item using a PUT request

Delete Line Item​

Delete a line item from the cart.

Workflow​

  1. Start with line-item
  2. DELETE line-item

Empty Cart​

Remove all line items from the cart.

Workflow​

  1. Start with cart
  2. GET the link with rel: lineitems
  3. DELETE 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​

  1. Start with line-item
  2. GET the link with rel: cart
  3. Render the response

Response Fields​

Type: carts.cart​

NameDescriptionType
total-quantityLists the total number of items in the cart.integer