---
schema_version: "1"
id: 7b2304cd18e0f236a903d2531e6ec3b1b6c600ad4e691b02d9d84ec28dfaf49b
title: CommerceCart Class
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexref/apex_ConnectAPI_CommerceCart_static_methods.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: ba0cac9b16881a58294a575971b0e832d460aa5f3b49b019ffec9c7aaccc425a
description: Get, create, update, calculate, and delete carts. Get cart items, add items to carts, update and delete cart items.These methods are for CommerceCart. All methods are static. Add an item to a cart of a specific currency. Add an item to a cart of a specific currency.Add a batch of up to 100 items to a cart.Add a batch of up to 100 items to a cart of a specific currency.Add an item to a cart. Apply a coupon to a cart. Apply a coupon to a cart. Copy the products from a cart to a wishlist.Calculate a cart.Calculate a cart.Create a cart.Create a cart from an approved quote, or duplicate a draft quote into a cart by converting the quote into cart items. Create a new quote from an active cart by converting cart items into quote line items. Clones an existing cart to create a secondary, read-only cart to support Pay Now functionality. Sets the guest cart status to PendingDelete in a B2B store.Delete a cart. Sets the guest cart status to PendingDelete in a B2B store or Closed in a D2C store. Delete a coupon from a cart. Delete a coupon from a cart. Delete an item from a cart.Delete an inventory reservation.Evaluate shipping costs for a cart.Evaluate taxes for a cart. Get coupons for a cart. Get coupons for a cart.Get promotions for a cart item.Get a promotion for a cart item.Get items in a cart.Get a page of items in a cart.Get a sorted page of items in a cart.Get a specified size page of items in a cart.Get a specified size, sorted page of items in a cart.Get a specified size, sorted page of items filtered by product fields in a cart.Get a specified size, sorted page of items filtered by product fields in a cart.Get a sorted page of items in a cart, including coupons and promotions.Get a specific, sorted page of items in a cart, including coupons and promotions.Get promotions for a cart.Get promotions for a cart in a specific currency.Get a cart.Get a cart in a specific currency.Get a cart or create an active cart if one doesn’t exist.Get a cart in a specific currency, or create an active cart if one doesn’t exist.Get cart items of a specific product.Get the items in a cart, sorted by product ID.Make a secondary cart a primary cart. Preserve cart contents when a guest logs in as an authenticated customer. Sets the guest cart status to PendingDelete in a B2B store or Closed in a D2C store.Set the visibility for cart messages.Update an item in a cart.Update an item in a cart of a specific currency.Update an item in a cart of a specific currency.Create or update an inventory reservation.
---
# CommerceCart Class

Get, create, update, calculate, and delete carts. Get cart items, add items to carts, update and delete cart items.

## Namespace

[ConnectApi](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_classes_connect_api.htm "The ConnectApi namespace (also called Connect in Apex) provides classes for accessing the same data available in Connect REST API. Use Connect in Apex to create custom experiences in Salesforce.")

## CommerceCart Methods

These methods are for CommerceCart. All methods are static.

- **[addItemToCart(webstoreId, effectiveAccountId, activeCartOrId, cartItemInput, currencyIsoCode)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_addItemToCart_9)**  
    Add an item to a cart of a specific currency.
- **[addItemToCart(webstoreId, effectiveAccountId, activeCartOrId, cartItemInput, currencyIsoCode, includeCartData)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_addItemToCart_10)**  
    Add an item to a cart of a specific currency.
- **[addItemsToCart(webstoreId, effectiveAccountId, activeCartOrId, cartItems)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_Commerce_addItemsToCart_1)**  
    Add a batch of up to 100 items to a cart.
- **[addItemsToCart(webstoreId, effectiveAccountId, activeCartOrId, cartItems, currencyIsoCode)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_addItemsToCart_2)**  
    Add a batch of up to 100 items to a cart of a specific currency.
- **[addItemToCart(webstoreId, effectiveAccountId, activeCartOrId, cartItemInput)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_Commerce_addItemToCart_1)**  
    Add an item to a cart.
- **[applyCartCoupon(webstoreId, effectiveAccountId, activeCartOrId, cartCouponInput)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_applyCartCoupon_1)**  
    Apply a coupon to a cart.
- **[applyCartCoupon(webstoreId, effectiveAccountId, activeCartOrId, cartCouponInput, currencyIsoCode)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_applyCartCoupon_4)**  
    Apply a coupon to a cart.
- **[copyCartToWishlist(webstoreId, effectiveAccountId, activeCartOrId, cartToWishlistInput)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_copyCartToWishlist_1)**  
    Copy the products from a cart to a wishlist.
- **[calculateCart(webstoreId, activeCartOrId, effectiveAccountId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_calculateCart_1)**  
    Calculate a cart.
- **[calculateCart(webstoreId, activeCartOrId, effectiveAccountId, calculateCartInput)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_calculateCart_2)**  
    Calculate a cart.
- **[createCart(webstoreId, cart)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_Commerce_createCart_1)**  
    Create a cart.
- **[createCartFromQuote(webstoreId, quoteId, cartFromQuoteInput)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_createCartFromQuote_1)**  
    Create a cart from an approved quote, or duplicate a draft quote into a cart by converting the quote into cart items.
- **[createQuoteFromCart(webstoreId, activeCartOrId, createQuoteFromCartInput)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_createQuoteFromCart_1)**  
    Create a new quote from an active cart by converting cart items into quote line items.
- **[cloneCart(webstoreId, activeCartOrId, targetEffectiveAccountId, targetType)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_cloneCart_1)**  
    Clones an existing cart to create a secondary, read-only cart to support Pay Now functionality. Sets the guest cart status to PendingDelete in a B2B store.
- **[deleteCart(webstoreId, effectiveAccountId, activeCartOrId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_deleteCart_1)**  
    Delete a cart. Sets the guest cart status to PendingDelete in a B2B store or Closed in a D2C store.
- **[deleteCartCoupon(webstoreId, effectiveAccountId, activeCartOrId, cartCouponId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_deleteCartCoupon_1)**  
    Delete a coupon from a cart.
- **[deleteCartCoupon(webstoreId, effectiveAccountId, activeCartOrId, cartCouponId, currencyIsoCode)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_deleteCartCoupon_2)**  
    Delete a coupon from a cart.
- **[deleteCartItem(webstoreId, effectiveAccountId, activeCartOrId, cartItemId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_Commerce_deleteCartItem_1)**  
    Delete an item from a cart.
- **[deleteInventoryReservation(webstoreId, activeCartOrId, effectiveAccountId) (Pilot)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_deleteInventoryReservation_1)**  
    Delete an inventory reservation.
- **[evaluateShipping(webstoreId, activeCartOrId, effectiveAccountId, cartEvaluateShippingInput)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_evaluateShipping_1)**  
    Evaluate shipping costs for a cart.
- **[evaluateTaxes(webstoreId, activeCartOrId, effectiveAccountId, cartEvaluateTaxInput)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_evaluateTaxes_1)**  
    Evaluate taxes for a cart.
- **[getCartCoupons(webstoreId, effectiveAccountId, activeCartOrId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_getCartCoupons_1)**  
    Get coupons for a cart.
- **[getCartCoupons(webstoreId, effectiveAccountId, activeCartOrId, currencyIsoCode)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_getCartCoupons_2)**  
    Get coupons for a cart.
- **[getCartItemPromotion(webstoreId, effectiveAccountId, activeCartOrId, cartItemPromotionCollectionInput)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_getCartItemPromotion_1)**  
    Get promotions for a cart item.
- **[getCartItemPromotion(webstoreId, effectiveAccountId, activeCartOrId, cartItemPromotionCollectionInput, currencyIsoCode)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_getCartItemPromotion_2)**  
    Get a promotion for a cart item.
- **[getCartItems(webstoreId, effectiveAccountId, activeCartOrId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_Commerce_getCartItems_6)**  
    Get items in a cart.
- **[getCartItems(webstoreId, effectiveAccountId, activeCartOrId, pageParam)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_Commerce_getCartItems_7)**  
    Get a page of items in a cart.
- **[getCartItems(webstoreId, effectiveAccountId, activeCartOrId, pageParam, sortParam)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_Commerce_getCartItems_8)**  
    Get a sorted page of items in a cart.
- **[getCartItems(webstoreId, effectiveAccountId, activeCartOrId, pageParam, pageSize)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_Commerce_getCartItems_9)**  
    Get a specified size page of items in a cart.
- **[getCartItems(webstoreId, effectiveAccountId, activeCartOrId, pageParam, pageSize, sortParam)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_Commerce_getCartItems_10)**  
    Get a specified size, sorted page of items in a cart.
- **[getCartItems(webstoreId, effectiveAccountId, activeCartOrId, productFields, pageParam, pageSize, sortParam)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_getCartItems_6)**  
    Get a specified size, sorted page of items filtered by product fields in a cart.
- **[getCartItems(webstoreId, effectiveAccountId, activeCartOrId, productFields, pageParam, pageSize, sortParam, currencyIsoCode)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_getCartItems_7)**  
    Get a specified size, sorted page of items filtered by product fields in a cart.
- **[getCartItems(webstoreId, effectiveAccountId, activeCartOrId, productFields, pageParam, pageSize, sortParam, currencyIsoCode, includePromotions, includeCoupons)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_getCartItems_8)**  
    Get a sorted page of items in a cart, including coupons and promotions.
- **[getCartItems(webstoreId, effectiveAccountId, activeCartOrId, productFields, pageParam, pageSize, sortParam, currencyIsoCode, includePromotions, includeCoupons, pageNumber)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_getCartItems_9)**  
    Get a specific, sorted page of items in a cart, including coupons and promotions.
- **[getCartPromotions(webstoreId, effectiveAccountId, activeCartOrId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_getCartPromotions_1)**  
    Get promotions for a cart.
- **[getCartPromotions(webstoreId, effectiveAccountId, activeCartOrId, currencyIsoCode)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_getCartPromotions_2)**  
    Get promotions for a cart in a specific currency.
- **[getCartSummary(webstoreId, effectiveAccountId, activeCartOrId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_Commerce_getCartSummary_1)**  
    Get a cart.
- **[getCartSummary(webstoreId, effectiveAccountId, activeCartOrId, currencyIsoCode)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_getCartSummary_3)**  
    Get a cart in a specific currency.
- **[getOrCreateActiveCartSummary(webstoreId, effectiveAccountId, activeCartOrId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_Commerce_getOrCreateActiveCartSummary_2)**  
    Get a cart or create an active cart if one doesn’t exist.
- **[getOrCreateActiveCartSummary(webstoreId, effectiveAccountId, activeCartOrId, currencyIsoCode)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_getOrCreateActiveCartSummary_5)**  
    Get a cart in a specific currency, or create an active cart if one doesn’t exist.
- **[getProductCartItem(webstoreId, effectiveAccountId, activeCartOrId, productId, currencyIsoCode)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_getProductCartItem_1)**  
    Get cart items of a specific product.
- **[getProductCartItems(webstoreId, effectiveAccountId, activeCartOrId, pageSize, pageNumber, currencyIsoCode)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_getProductCartItems_1)**  
    Get the items in a cart, sorted by product ID.
- **[makeCartPrimary(webstoreId, activeCartOrId, effectiveAccountId)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_makeCartPrimary_1)**  
    Make a secondary cart a primary cart.
- **[preserveGuestCart(webstoreId, effectiveAccountId, activeCartOrId, currencyIsoCode)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_preserveGuestCart_1)**  
    Preserve cart contents when a guest logs in as an authenticated customer. Sets the guest cart status to PendingDelete in a B2B store or Closed in a D2C store.
- **[setCartMessagesVisibility(webstoreId, activeCartOrId, effectiveAccountId, messageVisibility)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_setCartMessagesVisibility_1)**  
    Set the visibility for cart messages.
- **[updateCartItem(webstoreId, effectiveAccountId, activeCartOrId, cartItemId, cartItem)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_Commerce_updateCartItem_2)**  
    Update an item in a cart.
- **[updateCartItem(webstoreId, effectiveAccountId, activeCartOrId, cartItemId, cartItem, currencyIsoCode)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_updateCartItem_3)**  
    Update an item in a cart of a specific currency.
- **[updateCartItem(webstoreId, effectiveAccountId, activeCartOrId, cartItemId, cartItem, currencyIsoCode, includeCartData)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_updateCartItem_4)**  
    Update an item in a cart of a specific currency.
- **[upsertInventoryReservation(webstoreId, activeCartOrId, effectiveAccountId, cartInventoryReservationInput) (Pilot)](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_ConnectAPI_CommerceCart_static_methods.htm#apex_ConnectAPI_CommerceCart_upsertInventoryReservation_2)**  
    Create or update an inventory reservation.

### addItemToCart(webstoreId, effectiveAccountId, activeCartOrId, cartItemInput, currencyIsoCode)

Add an item to a cart of a specific currency.

#### API Version

57.0

#### Available to Guest Users

57.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartItem addItemToCart(String webstoreId, String effectiveAccountId, String activeCartOrId, ConnectApi.CartItemInput cartItemInput, String currencyIsoCode)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String Use active only for B2B Aura stores; all other stores must use current.

ID of the cart, active, or current. The current value indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

cartItemInput

Type: [ConnectApi.CartItemInput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_cart_item.htm "An item in a cart.")

A ConnectApi.CartItemInput object representing an item to add to the cart.

currencyIsoCode

Type: String

The currency ISO code of the cart.

#### Return Value

Type: [ConnectApi.CartItem](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_item.htm "An item in a cart.")

#### Usage

Buyers with read access to carts can add, update, and delete items in carts.

This method respects buyer View Product entitlements and only users entitled to view product data can access it.

### addItemToCart(webstoreId, effectiveAccountId, activeCartOrId, cartItemInput, currencyIsoCode, includeCartData)

Add an item to a cart of a specific currency.

#### API Version

64.0

#### Available to Guest Users

51.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartItem addItemToCart(String webstoreId, String effectiveAccountId, String activeCartOrId, ConnectApi.CartItemInput cartItemInput, String currencyIsoCode, Boolean includeCartData)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

cartItemInput

Type: [ConnectApi.CartItemInput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_cart_item.htm "An item in a cart.")

A ConnectApi.CartItemInput object representing an item to add to the cart.

currencyIsoCode

Type: String

The currency ISO code of the cart.

includeCartData

Type: Boolean

Specifies whether to return a collection of cart items in the response (true) or not (false). If unspecified, the default value is false. This parameter is supported for D2C stores with Faster Add-to-Cart disabled. The cart must also have fewer than 25 items.

#### Return Value

Type: [ConnectApi.CartItem](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_item.htm "An item in a cart.")

#### Usage

Buyers with read access to carts can add, update, and delete items in carts.

This method respects buyer View Product entitlements and only users entitled to view product data can access it.

### addItemsToCart(webstoreId, effectiveAccountId, activeCartOrId, cartItems)

Add a batch of up to 100 items to a cart.

#### API Version

49.0

#### Available to Guest Users

54.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.BatchResult\[\] addItemsToCart(String webstoreId, String effectiveAccountId, String activeCartOrId, List<ConnectApi.BatchInput> cartItems)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete.

cartItems

Type: [List](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_list.htm#apex_methods_system_list "Contains methods for the List collection type.")<[ConnectApi.BatchInput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_batch.htm "Construct a set of inputs to be passed into a method at the same time.")\>

The list can contain up to 100 ConnectApi.BatchInput objects. In the ConnectApi.BatchInput constructor, the input object must be [ConnectApi.CartItemInput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_cart_item.htm "An item in a cart.").

#### Return Value

Type: [ConnectApi.BatchResult](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_batch_result.htm "The result of an operation returned by a batch method.")\[\]

The ConnectApi.BatchResult.getResult() method returns a [ConnectApi.CartItem](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_item.htm "An item in a cart.") object.

The returned objects correspond to each of the input objects and are returned in the same order as the input objects.

The method call fails only if an error occurs that affects the entire operation (such as a parsing failure). If an individual object causes an error, the error is embedded within the ConnectApi.BatchResult list.

#### Usage

Buyers with read access to carts can add, update, and delete items in carts.

This method respects buyer View Product entitlements and only users entitled to view product data can access it.

### addItemsToCart(webstoreId, effectiveAccountId, activeCartOrId, cartItems, currencyIsoCode)

Add a batch of up to 100 items to a cart of a specific currency.

#### API Version

57.0

#### Available to Guest Users

57.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.BatchResult\[\] addItemsToCart(String webstoreId, String effectiveAccountId, String activeCartOrId, List<ConnectApi.BatchInput> cartItems, String currencyIsoCode)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

cartItems

Type: [List](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_list.htm#apex_methods_system_list "Contains methods for the List collection type.")<[ConnectApi.BatchInput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_batch.htm "Construct a set of inputs to be passed into a method at the same time.")\>

The list can contain up to 100 ConnectApi.BatchInput objects. In the ConnectApi.BatchInput constructor, the input object must be [ConnectApi.CartItemInput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_cart_item.htm "An item in a cart.").

currencyIsoCode

Type: String

The currency ISO code of the cart.

#### Return Value

Type: [ConnectApi.BatchResult](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_batch_result.htm "The result of an operation returned by a batch method.")\[\]

The ConnectApi.BatchResult.getResult() method returns a [ConnectApi.CartItem](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_item.htm "An item in a cart.") object.

The returned objects correspond to each of the input objects and are returned in the same order as the input objects.

The method call fails only if an error occurs that affects the entire operation (such as a parsing failure). If an individual object causes an error, the error is embedded within the ConnectApi.BatchResult list.

#### Usage

Buyers with read access to carts can add, update, and delete items in carts.

This method respects buyer View Product entitlements and only users entitled to view product data can access it.

### addItemToCart(webstoreId, effectiveAccountId, activeCartOrId, cartItemInput)

Add an item to a cart.

#### API Version

49.0

#### Available to Guest Users

54.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartItem addItemToCart(String webstoreId, String effectiveAccountId, String activeCartOrId, ConnectApi.CartItemInput cartItemInput)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete.

cartItemInput

Type: [ConnectApi.CartItemInput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_cart_item.htm "An item in a cart.")

A ConnectApi.CartItemInput object representing an item to add to the cart.

#### Return Value

Type: [ConnectApi.CartItem](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_item.htm "An item in a cart.")

#### Usage

Buyers with read access to carts can add, update, and delete items in carts.

This method respects buyer View Product entitlements and only users entitled to view product data can access it.

### applyCartCoupon(webstoreId, effectiveAccountId, activeCartOrId, cartCouponInput)

Apply a coupon to a cart.

#### API Version

54.0

#### Available to Guest Users

57.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartCouponCollection applyCartCoupon(String webstoreId, String effectiveAccountId, String activeCartOrId, ConnectApi.cartCouponInput cartCouponInput)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

cartCouponInput

Type: [ConnectApi.cartCouponInput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_cart_coupon.htm "Cart coupon input.")

Coupon code for the coupon.

#### Return Value

Type: [ConnectApi.CartCouponCollection](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_coupon_collection.htm "Collection of coupons related to a cart.")

### applyCartCoupon(webstoreId, effectiveAccountId, activeCartOrId, cartCouponInput, currencyIsoCode)

Apply a coupon to a cart.

#### API Version

57.0

#### Available to Guest Users

57.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartCouponCollection applyCartCoupon(String webstoreId, String effectiveAccountId, String activeCartOrId, ConnectApi.cartCouponInput cartCouponInput, String currencyIsoCode)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

cartCouponInput

Type: [ConnectApi.cartCouponInput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_cart_coupon.htm "Cart coupon input.")

Coupon code for the coupon.

currencyIsoCode

Type: String

Currency ISO code of the cart.

#### Return Value

Type: [ConnectApi.CartCouponCollection](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_coupon_collection.htm "Collection of coupons related to a cart.")

### copyCartToWishlist(webstoreId, effectiveAccountId, activeCartOrId, cartToWishlistInput)

Copy the products from a cart to a wishlist.

#### API Version

50.0

#### Available to Guest Users

54.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartToWishlistResult copyCartToWishlist(String webstoreId, String effectiveAccountId, String activeCartOrId, ConnectApi.CartToWishlistInput cartToWishlistInput)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

cartToWishlistInput

Type: [ConnectApi.CartToWishlistInput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_cart_to_wishlist.htm "Copy products from a cart to a wishlist.")

A ConnectApi.CartToWishlistInput object indicating the wishlist to copy products to.

#### Return Value

Type: [ConnectApi.CartToWishlistResult](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_to_wishlist_result.htm "Result of copying products from a cart to a wishlist.")

### calculateCart(webstoreId, activeCartOrId, effectiveAccountId)

Calculate a cart.

#### API Version

62.0

#### Available to Guest Users

62.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CalculateCartResult calculateCart(String webstoreId, String activeCartOrId, String effectiveAccountId)

#### Parameters

webstoreId

Type: String

ID of the webstore.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

#### Return Value

Type: [ConnectApi.CalculateCartResult](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_summary_result.htm "Result of a cart calculate request. Includes a cart summary with calculated cart values.")

#### Usage

Buyers with read access to carts can add, update, and delete items in carts.

This method respects buyer View Product entitlements and only users entitled to view product data can access it.

### calculateCart(webstoreId, activeCartOrId, effectiveAccountId, calculateCartInput)

Calculate a cart.

#### API Version

63.0

#### Available to Guest Users

62.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CalculateCartResult calculateCart(String webstoreId, String activeCartOrId, String effectiveAccountId, ConnectApi.CalculateCartInput calculateCartInput)

#### Parameters

webstoreId

Type: String

ID of the webstore.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

calculateCartInput

Type: [ConnectApi.CalculateCartInput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_cart_calculate.htm "Custom fields for a cart calculation.")

A ConnectApi.CalculateCartInput object representing any custom fields for the cart.

#### Return Value

Type: [ConnectApi.CalculateCartResult](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_summary_result.htm "Result of a cart calculate request. Includes a cart summary with calculated cart values.")

#### Usage

Buyers with read access to carts can add, update, and delete items in carts.

This method respects buyer View Product entitlements and only users entitled to view product data can access it.

### createCart(webstoreId, cart)

Create a cart.

#### API Version

49.0

#### Available to Guest Users

54.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartSummary createCart(String webstoreId, ConnectApi.CartInput cart)

#### Parameters

webstoreId

Type: String

ID of the webstore.

cart

Type: [ConnectApi.CartInput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_cart.htm "A cart.")

A ConnectApi.CartInput object representing a cart.

#### Return Value

Type: [ConnectApi.CartSummary](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_summary.htm "A cart summary.")

#### Usage

Buyers with read access to carts can create and delete carts.

### createCartFromQuote(webstoreId, quoteId, cartFromQuoteInput)

Create a cart from an approved quote, or duplicate a draft quote into a cart by converting the quote into cart items.

This method performs one of the following operations based on the quote status:

- Create Cart from Quote—
    - Create a cart from a quote only when its status is Approved or Accepted, as initiated by the Accept & Buy action on the My Quotes page of the B2B storefront.
    - All items are added at the negotiated and discounted prices.
    - A quote can be converted to a cart only once if the resulting cart is used to place an order. After the order is placed, the same quote can't be reused.
    - If the cart is cleared after conversion (before placing an order), the quote can be converted to a cart again.
- Duplicate Quote to Cart—
    - Duplicate the quote to cart, as initiated by the Duplicate to Cart action on the My Quotes page of the B2B storefront. This operation isn't supported only for quotes in Approved or Accepted status.
    - All items are added at their original prices.

Duplicate-to-cart and convert-to-cart operations succeed only when the cart has no matching products. For example, if both the quote and the cart contain Product A, the API returns an error. Partial conversion or duplication, promotions, and bonus products aren't supported.

Supported product types by license:

- Simple products: Supported with B2B Commerce only or B2B Commerce and Revenue Cloud licenses.
- Static bundles: Supported only with the B2B Commerce and Revenue Cloud license.
- Dynamic bundles: Supported only with the B2B Commerce and Revenue Cloud license.
- Subscription products: Not supported with either B2B Commerce Only or B2B Commerce and Revenue Cloud licenses.

#### API Version

67.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartFromQuoteOutput createCartFromQuote(String webstoreId, String quoteId, ConnectApi.CartFromQuoteInput cartFromQuoteInput)

#### Parameters

webstoreId

Type: String

ID of the webstore.

quoteId

Type: String

ID of the quote to convert to a cart.

cartFromQuoteInput

Type: [ConnectApi.CartFromQuoteInput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_cart_from_quote.htm "Input representation for creating a cart from a quote.")

Representation for creating a cart from a quote.

#### Return Value

Type: [ConnectApi.CartFromQuoteOutput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_from_quote_output.htm "Representation of the response for creating a cart from a quote.")

### createQuoteFromCart(webstoreId, activeCartOrId, createQuoteFromCartInput)

Create a new quote from an active cart by converting cart items into quote line items.

To access the method, your org must have the B2B Commerce license. The method is available only to authenticated users.

This method is used to create a quote from an active cart, retaining pricing and customer details. Buyers can also specify an expiration date and add comments for negotiation.

![Note](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/images/icon_note.png)

#### Note

Carts must contain at least one product to create a quote. Empty carts return an error. Promotions and bonus products aren't supported.

Supported product types by license:

- Simple products—Supported with B2B Commerce Only or B2B Commerce and Revenue Cloud licenses.
- Static bundles—Supported only with the B2B Commerce and Revenue Cloud licenses.
- Dynamic bundles—Supported only with the B2B Commerce and Revenue Cloud licenses.
- Subscription products—Not supported with either B2B Commerce Only or B2B Commerce and Revenue Cloud licenses.

#### API Version

66.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CreateQuoteFromCartOutput createQuoteFromCart(String webstoreId, String activeCartOrId, ConnectApi.CreateQuoteFromCartInput createQuoteFromCartInput)

#### Parameters

webstoreId

Type: String

Description

activeCartOrId

Type: String

Description

createQuoteFromCartInput

Type: [ConnectApi.CreateQuoteFromCartInput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_create_quote_from_cart.htm "Input representation for creating a quote from a cart.")

Description

#### Return Value

Type: [ConnectApi.CreateQuoteFromCartOutput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_create_quote_from_cart_output.htm "Representation of the response for creating a quote from a cart.")

### cloneCart(webstoreId, activeCartOrId, targetEffectiveAccountId, targetType)

Clones an existing cart to create a secondary, read-only cart to support Pay Now functionality. Sets the guest cart status to PendingDelete in a B2B store.

#### API Version

60.0

#### Available to Guest Users

60.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartSummary cloneCart(String webstoreId, String activeCartOrId, String targetEffectiveAccountId, String targetType)

#### Parameters

webstoreId

Type: String

ID of the webstore.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

targetEffectiveAccountId

Type: String

Effective Account ID associated with the cloned cart.

targetType

Type: String

Type of the cloned cart. Value is PayNowReadOnly.

#### Return Value

Type: [ConnectApi.CartSummary](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_summary.htm "A cart summary.")

#### Usage

The cloneCart method is valid only for the Pay Now feature. See [Salesforce Pay Now for Embedded Payment Solutions](https://help.salesforce.com/s/articleView?language=en_US&id=sf.pay_now_intro_prereqs.htm).

### deleteCart(webstoreId, effectiveAccountId, activeCartOrId)

Delete a cart. Sets the guest cart status to PendingDelete in a B2B store or Closed in a D2C store.

#### API Version

49.0

#### Available to Guest Users

54.0

#### Requires Chatter

No

#### Signature

public static Void deleteCart(String webstoreId, String effectiveAccountId, String activeCartOrId)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

#### Return Value

Type: Void

#### Usage

Buyers with read access to carts can create and delete carts.

### deleteCartCoupon(webstoreId, effectiveAccountId, activeCartOrId, cartCouponId)

Delete a coupon from a cart.

#### API Version

54.0

#### Available to Guest Users

57.0

#### Requires Chatter

No

#### Signature

public static Void deleteCartCoupon(String webstoreId, String effectiveAccountId, String activeCartOrId, String cartCouponId)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

cartCouponId

Type: String

ID of the cart coupon.

#### Return Value

Type: Void

### deleteCartCoupon(webstoreId, effectiveAccountId, activeCartOrId, cartCouponId, currencyIsoCode)

Delete a coupon from a cart.

#### API Version

57.0

#### Available to Guest Users

57.0

#### Requires Chatter

No

#### Signature

public static Void deleteCartCoupon(String webstoreId, String effectiveAccountId, String activeCartOrId, String cartCouponId, String currencyIsoCode)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

cartCouponId

Type: String

ID of the cart coupon.

currencyIsoCode

Type: String

Currency ISO code of the cart.

#### Return Value

Type: Void

### deleteCartItem(webstoreId, effectiveAccountId, activeCartOrId, cartItemId)

Delete an item from a cart.

#### API Version

49.0

#### Available to Guest Users

54.0

#### Requires Chatter

No

#### Signature

public static Void deleteCartItem(String webstoreId, String effectiveAccountId, String activeCartOrId, String cartItemId)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete.

cartItemId

Type: String

ID of the cart item.

#### Return Value

Type: Void

#### Usage

Buyers with read access to carts can add, update, and delete items in carts.

### deleteInventoryReservation(webstoreId, activeCartOrId, effectiveAccountId) (Pilot)

Delete an inventory reservation.

#### API Version

![Note](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/images/icon_note.png)

#### Note

This feature is not generally available and is being piloted with certain Customers subject to additional terms and conditions. It is not part of your purchased Services. This feature is subject to change, may be discontinued with no notice at any time in Salesforce’s sole discretion, and Salesforce may never make this feature generally available. Make your purchase decisions only on the basis of generally available products and features. This feature is made available on an AS IS basis and use of this feature is at your sole risk.

58.0

#### Available to Guest Users

58.0

#### Requires Chatter

No

#### Signature

public static Void deleteInventoryReservation(String webstoreId, String activeCartOrId, String effectiveAccountId)

#### Parameters

webstoreId

Type: String

ID of the webstore.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

#### Return Value

Type: Void

### evaluateShipping(webstoreId, activeCartOrId, effectiveAccountId, cartEvaluateShippingInput)

Evaluate shipping costs for a cart.

#### API Version

63.0

#### Available to Guest Users

63.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CalculateCartResult evaluateShipping(String webstoreId, String activeCartOrId, String effectiveAccountId, ConnectApi.CartEvaluateShippingInput cartEvaluateShippingInput)

#### Parameters

webstoreId

Type: String

ID of the webstore.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

cartEvaluateShippingInput

Type: [ConnectApi.CartEvaluateShippingInput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_cart_evaluate_shipping.htm "Shipping address and custom fields used to calculate shipping costs for a cart.")

A ConnectApi.CartEvaluateShippingInput object representing a shipping address and any custom fields.

#### Return Value

Type: [ConnectApi.CalculateCartResult](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_summary_result.htm "Result of a cart calculate request. Includes a cart summary with calculated cart values.")

#### Usage

Buyers with read access to carts can add, update, and delete items in carts.

This method respects buyer View Product entitlements and only users entitled to view product data can access it.

### evaluateTaxes(webstoreId, activeCartOrId, effectiveAccountId, cartEvaluateTaxInput)

Evaluate taxes for a cart.

#### API Version

63.0

#### Available to Guest Users

63.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CalculateCartResult evaluateTaxes(String webstoreId, String activeCartOrId, String effectiveAccountId, ConnectApi.CartEvaluateTaxInput cartEvaluateTaxInput)

#### Parameters

webstoreId

Type: String

ID of the webstore.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

cartEvaluateTaxInput

Type: [ConnectApi.CartEvaluateTaxInput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_cart_evaluate_tax.htm "Shipping address and custom fields used to calculate taxes for a cart.")

A ConnectApi.CartEvaluateTaxInput object representing a shipping address and any custom fields.

#### Return Value

Type: [ConnectApi.CalculateCartResult](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_summary_result.htm "Result of a cart calculate request. Includes a cart summary with calculated cart values.")

#### Usage

Buyers with read access to carts can add, update, and delete items in carts.

This method respects buyer View Product entitlements and only users entitled to view product data can access it.

### getCartCoupons(webstoreId, effectiveAccountId, activeCartOrId)

Get coupons for a cart.

#### API Version

54.0

#### Available to Guest Users

57.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartCouponCollection getCartCoupons(String webstoreId, String effectiveAccountId, String activeCartOrId)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

#### Return Value

Type: [ConnectApi.CartCouponCollection](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_coupon_collection.htm "Collection of coupons related to a cart.")

### getCartCoupons(webstoreId, effectiveAccountId, activeCartOrId, currencyIsoCode)

Get coupons for a cart.

#### API Version

57.0

#### Available to Guest Users

57.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartCouponCollection getCartCoupons(String webstoreId, String effectiveAccountId, String activeCartOrId, String currencyIsoCode)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

#### Return Value

Type: [ConnectApi.CartCouponCollection](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_coupon_collection.htm "Collection of coupons related to a cart.")

### getCartItemPromotion(webstoreId, effectiveAccountId, activeCartOrId, cartItemPromotionCollectionInput)

Get promotions for a cart item.

#### API Version

52.0

#### Available to Guest Users

57.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartItemPromotionCollectionOutputRepresentation getCartItemPromotion(String webstoreId, String effectiveAccountId, String activeCartOrId, ConnectApi.CartItemPromotionCollectionInputRepresentation cartItemPromotionCollectionInput)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

cartItemPromotionCollectionInput

Type: [ConnectApi.CartItemPromotionCollectionInputRepresentation](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_cart_item_promotion_collection.htm "Promotions for a cart item.")

Promotions for a cart item.

#### Return Value

Type: [ConnectApi.CartItemPromotionCollectionOutputRepresentation](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_item_promotion_collection_output.htm "Promotions for the items in a cart.")

### getCartItemPromotion(webstoreId, effectiveAccountId, activeCartOrId, cartItemPromotionCollectionInput, currencyIsoCode)

Get a promotion for a cart item.

#### API Version

57.0

#### Available to Guest Users

57.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartItemPromotionCollectionOutputRepresentation getCartItemPromotion(String webstoreId, String effectiveAccountId, String activeCartOrId, ConnectApi.CartItemPromotionCollectionInputRepresentation cartItemPromotionCollectionInput, String currencyIsoCode)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

cartItemPromotionCollectionInput

Type: [ConnectApi.CartItemPromotionCollectionInputRepresentation](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_cart_item_promotion_collection.htm "Promotions for a cart item.")

Promotions for a cart item.

currencyIsoCode

Type: String

Currency ISO code of the cart.

#### Return Value

Type: [ConnectApi.CartItemPromotionCollectionOutputRepresentation](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_item_promotion_collection_output.htm "Promotions for the items in a cart.")

### getCartItems(webstoreId, effectiveAccountId, activeCartOrId)

Get items in a cart.

#### API Version

49.0

#### Available to Guest Users

54.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartItemCollection getCartItems(String webstoreId, String effectiveAccountId, String activeCartOrId)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete.

#### Return Value

Type: [ConnectApi.CartItemCollection](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_item_collection.htm "A collection of items in a cart.")

### getCartItems(webstoreId, effectiveAccountId, activeCartOrId, pageParam)

Get a page of items in a cart.

#### API Version

49.0

#### Available to Guest Users

54.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartItemCollection getCartItems(String webstoreId, String effectiveAccountId, String activeCartOrId, String pageParam)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete.

pageParam

Type: String

Specifies the page token to use to view a page of information. Page tokens are returned as part of the response class, such as currentPageToken or nextPageToken. If you pass in null, the first page is returned.

#### Return Value

Type: [ConnectApi.CartItemCollection](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_item_collection.htm "A collection of items in a cart.")

### getCartItems(webstoreId, effectiveAccountId, activeCartOrId, pageParam, sortParam)

Get a sorted page of items in a cart.

#### API Version

49.0

#### Available to Guest Users

54.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartItemCollection getCartItems(String webstoreId, String effectiveAccountId, String activeCartOrId, String pageParam, ConnectApi.CartItemSortOrder sortParam)

#### Parameters

**webstoreId**

Type: String

ID of the webstore.

**effectiveAccountId**

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

**activeCartOrId**

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete.

**pageParam**

Type: String

Specifies the page token to use to view a page of information. Page tokens are returned as part of the response class, such as currentPageToken or nextPageToken. If you pass in null, the first page is returned.

**sortParam**

Type: [ConnectApi.CartItemSortOrder](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/connectAPI_enums.htm#cartItemSortOrderEnum)

Sort order for items in a cart. Values are:

- CreatedDateAsc—Sorts by oldest creation date.
- CreatedDateDesc—Sorts by most recent creation date.
- NameAsc—Sorts by name in ascending alphabetical order (A–Z).
- NameDesc—Sorts by name in descending alphabetical order (Z–A).
- SalesPriceAsc—Sorts from lowest to highest negotiated price.
- SalesPriceDesc—Sorts from highest to lowest negotiated price.

If null, the default is CreatedDateDesc.

#### Return Value

Type: [ConnectApi.CartItemCollection](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_item_collection.htm "A collection of items in a cart.")

### getCartItems(webstoreId, effectiveAccountId, activeCartOrId, pageParam, pageSize)

Get a specified size page of items in a cart.

#### API Version

49.0

#### Available to Guest Users

54.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartItemCollection getCartItems(String webstoreId, String effectiveAccountId, String activeCartOrId, String pageParam, Integer pageSize)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete.

pageParam

Type: String

Specifies the page token to use to view a page of information. Page tokens are returned as part of the response class, such as currentPageToken or nextPageToken. If you pass in null, the first page is returned.

pageSize

Type: Integer

Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

#### Return Value

Type: [ConnectApi.CartItemCollection](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_item_collection.htm "A collection of items in a cart.")

### getCartItems(webstoreId, effectiveAccountId, activeCartOrId, pageParam, pageSize, sortParam)

Get a specified size, sorted page of items in a cart.

#### API Version

49.0

#### Available to Guest Users

54.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartItemCollection getCartItems(String webstoreId, String effectiveAccountId, String activeCartOrId, String pageParam, Integer pageSize, ConnectApi.CartItemSortOrder sortParam)

#### Parameters

**webstoreId**

Type: String

ID of the webstore.

**effectiveAccountId**

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

**activeCartOrId**

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete.

**pageParam**

Type: String

Specifies the page token to use to view a page of information. Page tokens are returned as part of the response class, such as currentPageToken or nextPageToken. If you pass in null, the first page is returned.

**pageSize**

Type: Integer

Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

**sortParam**

Type: [ConnectApi.CartItemSortOrder](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/connectAPI_enums.htm#cartItemSortOrderEnum)

Sort order for items in a cart. Values are:

- CreatedDateAsc—Sorts by oldest creation date.
- CreatedDateDesc—Sorts by most recent creation date.
- NameAsc—Sorts by name in ascending alphabetical order (A–Z).
- NameDesc—Sorts by name in descending alphabetical order (Z–A).
- SalesPriceAsc—Sorts from lowest to highest negotiated price.
- SalesPriceDesc—Sorts from highest to lowest negotiated price.

If null, the default is CreatedDateDesc.

#### Return Value

Type: [ConnectApi.CartItemCollection](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_item_collection.htm "A collection of items in a cart.")

### getCartItems(webstoreId, effectiveAccountId, activeCartOrId, productFields, pageParam, pageSize, sortParam)

Get a specified size, sorted page of items filtered by product fields in a cart.

#### API Version

49.0

#### Available to Guest Users

54.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartItemCollection getCartItems(String webstoreId, String effectiveAccountId, String activeCartOrId, String productFields, String pageParam, Integer pageSize, ConnectApi.CartItemSortOrder sortParam)

#### Parameters

**webstoreId**

Type: String

ID of the webstore.

**effectiveAccountId**

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

**activeCartOrId**

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

**productFields**

Type: String

Comma-separated list of up to 15 product fields. Results include fields that you have access to. Some product fields (such as productName and sku) are returned even when not included in the productFields parameter.

**pageParam**

Type: String

Specifies the page token to use to view a page of information. Page tokens are returned as part of the response class, such as currentPageToken or nextPageToken. If you pass in null, the first page is returned.

**pageSize**

Type: Integer

Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

**sortParam**

Type: [ConnectApi.CartItemSortOrder](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/connectAPI_enums.htm#cartItemSortOrderEnum)

Sort order for items in a cart. Values are:

- CreatedDateAsc—Sorts by oldest creation date.
- CreatedDateDesc—Sorts by most recent creation date.
- NameAsc—Sorts by name in ascending alphabetical order (A–Z).
- NameDesc—Sorts by name in descending alphabetical order (Z–A).
- SalesPriceAsc—Sorts from lowest to highest negotiated price.
- SalesPriceDesc—Sorts from highest to lowest negotiated price.

If null, the default is CreatedDateDesc.

#### Return Value

Type: [ConnectApi.CartItemCollection](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_item_collection.htm "A collection of items in a cart.")

### getCartItems(webstoreId, effectiveAccountId, activeCartOrId, productFields, pageParam, pageSize, sortParam, currencyIsoCode)

Get a specified size, sorted page of items filtered by product fields in a cart.

#### API Version

57.0

#### Available to Guest Users

57.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartItemCollection getCartItems(String webstoreId, String effectiveAccountId, String activeCartOrId, String productFields, String pageParam, Integer pageSize, ConnectApi.CartItemSortOrder sortParam, String currencyIsoCode)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

productFields

Type: String

Comma-separated list of up to 15 product fields. Results include fields that you have access to. Some product fields (such as productName and sku) are returned even when not included in the productFields parameter.

pageParam

Type: String

Specifies the page token to use to view a page of information. Page tokens are returned as part of the response class, such as currentPageToken or nextPageToken. If you pass in null, the first page is returned.

pageSize

Type: Integer

Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

currencyIsoCode

Type: String

Currency ISO code of the cart.

#### Return Value

Type: [ConnectApi.CartItemCollection](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_item_collection.htm "A collection of items in a cart.")

### getCartItems(webstoreId, effectiveAccountId, activeCartOrId, productFields, pageParam, pageSize, sortParam, currencyIsoCode, includePromotions, includeCoupons)

Get a sorted page of items in a cart, including coupons and promotions.

#### API Version

59.0

#### Available to Guest Users

54.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartItemCollection getCartItems(String webstoreId, String effectiveAccountId, String activeCartOrId, String productFields, String pageParam, Integer pageSize, ConnectApi.CartItemSortOrder sortParam, String currencyIsoCode, Boolean includePromotions, Boolean includeCoupons)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

productFields

Type: String

Comma-separated list of up to 15 product fields. Results include fields that you have access to. Some product fields (such as productName and sku) are returned even when not included in the productFields parameter.

pageParam

Type: String

Specifies the page token to use to view a page of information. Page tokens are returned as part of the response class, such as currentPageToken or nextPageToken. If you pass in null, the first page is returned.

pageSize

Type: Integer

Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

includePromotions

Type: Boolean

Indicates whether to include coupons (True) or not (False)

includeCoupons

Type: Boolean

Indicates whether to include promotions (True) or not (False).

#### Return Value

Type: [ConnectApi.CartItemCollection](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_item_collection.htm "A collection of items in a cart.")

### getCartItems(webstoreId, effectiveAccountId, activeCartOrId, productFields, pageParam, pageSize, sortParam, currencyIsoCode, includePromotions, includeCoupons, pageNumber)

Get a specific, sorted page of items in a cart, including coupons and promotions.

#### API Version

60.0

#### Available to Guest Users

54.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartItemCollection getCartItems(String webstoreId, String effectiveAccountId, String activeCartOrId, String productFields, String pageParam, Integer pageSize, ConnectApi.CartItemSortOrder sortParam, String currencyIsoCode, Boolean includePromotions, Boolean includeCoupons, Integer pageNumber)

#### Parameters

**webstoreId**

Type: String

ID of the webstore.

**effectiveAccountId**

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

**activeCartOrId**

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

**productFields**

Type: String

Comma-separated list of up to 15 product fields. Results include fields that you have access to. Some product fields (such as productName and sku) are returned even when not included in the productFields parameter.

**pageParam**

Specifies the page token to use to view a page of information. Page tokens are returned as part of the response class, such as currentPageToken or nextPageToken. If you pass in null, the first page is returned.

Description

**pageSize**

Type: Integer

Specifies the number of items per page. Valid values are from 1 through 100. If you pass in null, the default size is 25.

**sortParam**

Type: [ConnectApi.CartItemSortOrder](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/connectAPI_enums.htm#cartItemSortOrderEnum)

Sort order for items in a cart. Values are:

- CreatedDateAsc—Sorts by oldest creation date.
- CreatedDateDesc—Sorts by most recent creation date.
- NameAsc—Sorts by name in ascending alphabetical order (A–Z).
- NameDesc—Sorts by name in descending alphabetical order (Z–A).
- SalesPriceAsc—Sorts from lowest to highest negotiated price.
- SalesPriceDesc—Sorts from highest to lowest negotiated price.

If null, the default is CreatedDateDesc.

**includePromotions**

Type: Boolean

Indicates whether to include coupons (True) or not (False)

**includeCoupons**

Type: Boolean

Indicates whether to include promotions (True) or not (False).

**pageNumber**

Type: Integer

Specifies the requested page number.

#### Return Value

Type: [ConnectApi.CartItemCollection](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_item_collection.htm "A collection of items in a cart.")

### getCartPromotions(webstoreId, effectiveAccountId, activeCartOrId)

Get promotions for a cart.

#### API Version

53.0

#### Available to Guest Users

57.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartPromotionCollection getCartPromotions(String webstoreId, String effectiveAccountId, String activeCartOrId)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

#### Return Value

Type: [ConnectApi.CartPromotionCollection](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_promotion_collection.htm "All the promotions associated with the cart.")

### getCartPromotions(webstoreId, effectiveAccountId, activeCartOrId, currencyIsoCode)

Get promotions for a cart in a specific currency.

#### API Version

57.0

#### Available to Guest Users

57.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartPromotionCollection getCartPromotions(String webstoreId, String effectiveAccountId, String activeCartOrId, String currencyIsoCode)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

currencyIsoCode

Type: String

Currency ISO code of the cart.

#### Return Value

Type: [ConnectApi.CartPromotionCollection](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_promotion_collection.htm "All the promotions associated with the cart.")

### getCartSummary(webstoreId, effectiveAccountId, activeCartOrId)

Get a cart.

#### API Version

49.0

#### Available to Guest Users

54.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartSummary getCartSummary(String webstoreId, String effectiveAccountId, String activeCartOrId)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete. If you specify active and there isn’t an active cart, you get an error.

#### Return Value

Type: [ConnectApi.CartSummary](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_summary.htm "A cart summary.")

### getCartSummary(webstoreId, effectiveAccountId, activeCartOrId, currencyIsoCode)

Get a cart in a specific currency.

#### API Version

57.0

#### Available to Guest Users

57.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartSummary getCartSummary(String webstoreId, String effectiveAccountId, String activeCartOrId, String currencyIsoCode)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

currencyIsoCode

Type: String

Currency ISO code of the cart.

#### Return Value

Type: [ConnectApi.CartSummary](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_summary.htm "A cart summary.")

### getOrCreateActiveCartSummary(webstoreId, effectiveAccountId, activeCartOrId)

Get a cart or create an active cart if one doesn’t exist.

#### API Version

49.0

#### Available to Guest Users

54.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartSummary getOrCreateActiveCartSummary(String webstoreId, String effectiveAccountId, String activeCartOrId)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete. If you specify active and there isn’t an active cart, one is created.

#### Return Value

Type: [ConnectApi.CartSummary](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_summary.htm "A cart summary.")

#### Usage

Buyers with read access to carts can create and delete carts.

### getOrCreateActiveCartSummary(webstoreId, effectiveAccountId, activeCartOrId, currencyIsoCode)

Get a cart in a specific currency, or create an active cart if one doesn’t exist.

#### API Version

57.0

#### Available to Guest Users

57.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartSummary getOrCreateActiveCartSummary(String webstoreId, String effectiveAccountId, String activeCartOrId, String currencyIsoCode)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

currencyIsoCode

Type: String

Currency ISO code of the cart.

#### Return Value

Type: [ConnectApi.CartSummary](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_summary.htm "A cart summary.")

#### Usage

Buyers with read access to carts can create and delete carts.

### getProductCartItem(webstoreId, effectiveAccountId, activeCartOrId, productId, currencyIsoCode)

Get cart items of a specific product.

#### API Version

60.0

#### Available to Guest Users

60.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.ProductCartItem getProductCartItem(String webstoreId, String effectiveAccountId, String activeCartOrId, String productId, String currencyIsoCode)

#### Parameters

webstoreId

Type: String

ID of the web store.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If unspecified, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

currencyIsoCode

Type: String

Currency ISO code of the cart.

webstoreId

Type: String

ID of the product.

#### Return Value

Type: [ConnectApi.ProductCartItem](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_product_cart_item.htm "Cart items of a specific product type.")

### getProductCartItems(webstoreId, effectiveAccountId, activeCartOrId, pageSize, pageNumber, currencyIsoCode)

Get the items in a cart, sorted by product ID.

#### API Version

60.0

#### Available to Guest Users

60.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.ProductCartItemCollection getProductCartItems(String webstoreId, String effectiveAccountId, String activeCartOrId, Integer pageSize, Integer pageNumber, String currencyIsoCode)

#### Parameters

activeCartOrId

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

currencyIsoCode

Type: String

Currency ISO code of the cart.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If unspecified, the default value is determined from context.

pageNumber

Type: Integer

Specifies the requested page number.

pageSize

Type: Integer

Specifies the number of items per page. Valid values are from 1 through 100. If you don’t specify a value, the default size is 25.

webstoreId

Type: String

ID of the web store.

#### Return Value

Type: [ConnectApi.ProductCartItemCollection](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_product_cart_item_collection.htm "Items in the cart, grouped by product type.")

### makeCartPrimary(webstoreId, activeCartOrId, effectiveAccountId)

Make a secondary cart a primary cart.

#### API Version

53.0

#### Available to Guest Users

56.0

#### Requires Chatter

Yes

#### Signature

public static ConnectApi.CommerceActionResult makeCartPrimary(String webstoreId, String activeCartOrId, String effectiveAccountId)

#### Parameters

webstoreId

Type: String

ID of the webstore.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

#### Return Value

Type: [ConnectApi.CommerceActionResult](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_commerce_action_result.htm "Result of executing a commerce action.")

### preserveGuestCart(webstoreId, effectiveAccountId, activeCartOrId, currencyIsoCode)

Preserve cart contents when a guest logs in as an authenticated customer. Sets the guest cart status to PendingDelete in a B2B store or Closed in a D2C store.

#### API Version

60.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.PreserveCart preserveGuestCart(String webstoreId, String effectiveAccountId, String activeCartOrId, String currencyIsoCode)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made. If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

currencyIsoCode

Type: String

The currency ISO code of the cart.

#### Return Value

Type: [ConnectApi.PreserveCart](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_preserve_cart_output.htm "Represents a preserved cart.")

### setCartMessagesVisibility(webstoreId, activeCartOrId, effectiveAccountId, messageVisibility)

Set the visibility for cart messages.

#### API Version

50.0

#### Available to Guest Users

54.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartMessagesVisibilityResult setCartMessagesVisibility(String webstoreId, String activeCartOrId, String effectiveAccountId, ConnectApi.CartMessagesVisibilityInput messageVisibility)

#### Parameters

webstoreId

Type: String

ID of the webstore.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

messageVisibility

Type: [ConnectApi.CartMessagesVisibilityInput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_cart_messages_visibility.htm "Set the visibility for cart messages.")

A ConnectApi.CartMessagesVisibilityInput object specifying the visibility setting.

#### Return Value

Type: [ConnectApi.CartMessagesVisibilityResult](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_messages_visibility_result.htm "Result of setting the visibility for cart messages.")

### updateCartItem(webstoreId, effectiveAccountId, activeCartOrId, cartItemId, cartItem)

Update an item in a cart.

#### API Version

49.0

#### Available to Guest Users

54.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartItem updateCartItem(String webstoreId, String effectiveAccountId, String activeCartOrId, String cartItemId, ConnectApi.CartItemInput cartItem)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete.

cartItemId

Type: String

ID of the cart item.

cartItem

Type: [ConnectApi.CartItemInput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_cart_item.htm "An item in a cart.")

A ConnectApi.CartItemInput object representing a cart item to update.

#### Return Value

Type: [ConnectApi.CartItem](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_item.htm "An item in a cart.")

#### Usage

Buyers with read access to carts can add, update, and delete items in carts.

This method respects buyer View Product entitlements and only users entitled to view product data can access it.

### updateCartItem(webstoreId, effectiveAccountId, activeCartOrId, cartItemId, cartItem, currencyIsoCode)

Update an item in a cart of a specific currency.

#### API Version

57.0

#### Available to Guest Users

57.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartItem updateCartItem(String webstoreId, String effectiveAccountId, String activeCartOrId, String cartItemId, ConnectApi.CartItemInput cartItem, String currencyIsoCode)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

cartItemId

Type: String

ID of the cart item.

cartItem

Type: [ConnectApi.CartItemInput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_cart_item.htm "An item in a cart.")

A ConnectApi.CartItemInput object representing a cart item to update.

currencyIsoCode

Type: String

The currency ISO code of the cart.

#### Return Value

Type: [ConnectApi.CartItem](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_item.htm "An item in a cart.")

#### Usage

Buyers with read access to carts can add, update, and delete items in carts.

This method respects buyer View Product entitlements and only users entitled to view product data can access it.

### updateCartItem(webstoreId, effectiveAccountId, activeCartOrId, cartItemId, cartItem, currencyIsoCode, includeCartData)

Update an item in a cart of a specific currency.

#### API Version

64.0

#### Available to Guest Users

51.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartItem updateCartItem(String webstoreId, String effectiveAccountId, String activeCartOrId, String cartItemId, ConnectApi.CartItemInput cartItem, String currencyIsoCode, Boolean includeCartData)

#### Parameters

webstoreId

Type: String

ID of the webstore.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value is available in version 50.0 and later and indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

cartItemId

Type: String

ID of the cart item.

cartItem

Type: [ConnectApi.CartItemInput](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_cart_item.htm "An item in a cart.")

A ConnectApi.CartItemInput object representing a cart item to update.

currencyIsoCode

Type: String

The currency ISO code of the cart.

currencyIsoCode

Type: String

Description

includeCartData

Type: Boolean

Specifies whether to return a collection of cart items in the response (true) or not (false). If unspecified, the default value is false. This parameter is supported for D2C stores with Faster Add-to-Cart disabled. The cart must also have fewer than 25 items.

#### Return Value

Type: [ConnectApi.CartItem](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_item.htm "An item in a cart.")

#### Usage

Buyers with read access to carts can add, update, and delete items in carts.

This method respects buyer View Product entitlements and only users entitled to view product data can access it.

### upsertInventoryReservation(webstoreId, activeCartOrId, effectiveAccountId, cartInventoryReservationInput) (Pilot)

Create or update an inventory reservation.

#### API Version

![Note](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/images/icon_note.png)

#### Note

This feature is not generally available and is being piloted with certain Customers subject to additional terms and conditions. It is not part of your purchased Services. This feature is subject to change, may be discontinued with no notice at any time in Salesforce’s sole discretion, and Salesforce may never make this feature generally available. Make your purchase decisions only on the basis of generally available products and features. This feature is made available on an AS IS basis and use of this feature is at your sole risk.

58.0

#### Available to Guest Users

58.0

#### Requires Chatter

No

#### Signature

public static ConnectApi.CartInventoryReservationOutputRepresentation upsertInventoryReservation(String webstoreId, String activeCartOrId, String effectiveAccountId, ConnectApi.CartInventoryReservationInputRepresentation cartInventoryReservationInput)

#### Parameters

webstoreId

Type: String

ID of the webstore.

activeCartOrId

Type: String

ID of the cart, active, or current. The current value indicates a cart with a status that isn’t Closed or PendingDelete. Use active only for B2B Aura stores; all other stores must use current.

effectiveAccountId

Type: String

ID of the buyer account or guest buyer profile for which the request is made.If null, the default value is determined from context.

cartInventoryReservationInput

Type: [ConnectApi.CartInventoryReservationInputRepresentation](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_input_cart_inventory_reservation.htm "Input representation to create or update a reservation.")

A ConnectApi.CartInventoryReservationInputRepresentation input class indicating the reservation duration.

#### Return Value

Type: [ConnectApi.CartInventoryReservationOutputRepresentation](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_connectapi_output_cart_inventory_reservation_output.htm "Inventory Reservation")