Skip to main content
Version: 7.5.x

Carts

Entry Point: /carts/{scope}/default

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:

  • You can’t delete a cart, you can only empty a cart of its contents

  • You do not need to instantiate the cart, a cart is always available

  • 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 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 detail(s)
  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

Add Item To Default Cart​

Add an item to the user’s default cart.

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

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

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 Cart Memberships​

Retrieves the list of carts that the item has been added to. The list is empty if the item is not in your cart.

Workflow​

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

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

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