CommerceCart Class

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

ConnectApi

These methods are for CommerceCart. All methods are static.

Add an item to a cart of a specific currency.

57.0

57.0

No

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

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

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

currencyIsoCode

Type: String

The currency ISO code of the cart.

Type: ConnectApi.CartItem

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.

Add an item to a cart of a specific currency.

64.0

51.0

No

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

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

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.

Type: ConnectApi.CartItem

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.

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

49.0

54.0

No

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

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<ConnectApi.BatchInput>

The list can contain up to 100 ConnectApi.BatchInput objects. In the ConnectApi.BatchInput constructor, the input object must be ConnectApi.CartItemInput.

Type: ConnectApi.BatchResult[]

The ConnectApi.BatchResult.getResult() method returns a ConnectApi.CartItem 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.

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.

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

57.0

57.0

No

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

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<ConnectApi.BatchInput>

The list can contain up to 100 ConnectApi.BatchInput objects. In the ConnectApi.BatchInput constructor, the input object must be ConnectApi.CartItemInput.

currencyIsoCode

Type: String

The currency ISO code of the cart.

Type: ConnectApi.BatchResult[]

The ConnectApi.BatchResult.getResult() method returns a ConnectApi.CartItem 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.

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.

Add an item to a cart.

49.0

54.0

No

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

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

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

Type: ConnectApi.CartItem

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.

Apply a coupon to a cart.

54.0

57.0

No

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

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

Coupon code for the coupon.

Type: ConnectApi.CartCouponCollection

Apply a coupon to a cart.

57.0

57.0

No

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

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

Coupon code for the coupon.

currencyIsoCode

Type: String

Currency ISO code of the cart.

Type: ConnectApi.CartCouponCollection

Copy the products from a cart to a wishlist.

50.0

54.0

No

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

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

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

Type: ConnectApi.CartToWishlistResult

Calculate a cart.

62.0

62.0

No

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

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.

Type: ConnectApi.CalculateCartResult

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.

Calculate a cart.

63.0

62.0

No

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

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

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

Type: ConnectApi.CalculateCartResult

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.

Create a cart.

49.0

54.0

No

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

webstoreId

Type: String

ID of the webstore.

cart

Type: ConnectApi.CartInput

A ConnectApi.CartInput object representing a cart.

Type: ConnectApi.CartSummary

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

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.

67.0

No

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

webstoreId

Type: String

ID of the webstore.

quoteId

Type: String

ID of the quote to convert to a cart.

cartFromQuoteInput

Type: ConnectApi.CartFromQuoteInput

Representation for creating a cart from a quote.

Type: ConnectApi.CartFromQuoteOutput

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.

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.

66.0

No

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

webstoreId

Type: String

Description

activeCartOrId

Type: String

Description

createQuoteFromCartInput

Type: ConnectApi.CreateQuoteFromCartInput

Description

Type: ConnectApi.CreateQuoteFromCartOutput

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.

60.0

60.0

No

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

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.

Type: ConnectApi.CartSummary

The cloneCart method is valid only for the Pay Now feature. See Salesforce Pay Now for Embedded Payment Solutions.

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

49.0

54.0

No

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

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.

Type: Void

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

Delete a coupon from a cart.

54.0

57.0

No

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

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.

Type: Void

Delete a coupon from a cart.

57.0

57.0

No

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

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.

Type: Void

Delete an item from a cart.

49.0

54.0

No

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

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.

Type: Void

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

Delete an inventory reservation.

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

58.0

No

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

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.

Type: Void

Evaluate shipping costs for a cart.

63.0

63.0

No

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

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

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

Type: ConnectApi.CalculateCartResult

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.

Evaluate taxes for a cart.

63.0

63.0

No

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

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

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

Type: ConnectApi.CalculateCartResult

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.

Get coupons for a cart.

54.0

57.0

No

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

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.

Type: ConnectApi.CartCouponCollection

Get coupons for a cart.

57.0

57.0

No

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

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.

Type: ConnectApi.CartCouponCollection

Get promotions for a cart item.

52.0

57.0

No

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

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

Promotions for a cart item.

Type: ConnectApi.CartItemPromotionCollectionOutputRepresentation

Get a promotion for a cart item.

57.0

57.0

No

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

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

Promotions for a cart item.

currencyIsoCode

Type: String

Currency ISO code of the cart.

Type: ConnectApi.CartItemPromotionCollectionOutputRepresentation

Get items in a cart.

49.0

54.0

No

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

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.

Type: ConnectApi.CartItemCollection

Get a page of items in a cart.

49.0

54.0

No

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

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.

Type: ConnectApi.CartItemCollection

Get a sorted page of items in a cart.

49.0

54.0

No

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

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

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.

Type: ConnectApi.CartItemCollection

Get a specified size page of items in a cart.

49.0

54.0

No

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

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.

Type: ConnectApi.CartItemCollection

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

49.0

54.0

No

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

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

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.

Type: ConnectApi.CartItemCollection

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

49.0

54.0

No

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

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

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.

Type: ConnectApi.CartItemCollection

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

57.0

57.0

No

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

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.

Type: ConnectApi.CartItemCollection

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

59.0

54.0

No

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)

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).

Type: ConnectApi.CartItemCollection

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

60.0

54.0

No

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)

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

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.

Type: ConnectApi.CartItemCollection

Get promotions for a cart.

53.0

57.0

No

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

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.

Type: ConnectApi.CartPromotionCollection

Get promotions for a cart in a specific currency.

57.0

57.0

No

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

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.

Type: ConnectApi.CartPromotionCollection

Get a cart.

49.0

54.0

No

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

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.

Type: ConnectApi.CartSummary

Get a cart in a specific currency.

57.0

57.0

No

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

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.

Type: ConnectApi.CartSummary

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

49.0

54.0

No

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

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.

Type: ConnectApi.CartSummary

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

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

57.0

57.0

No

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

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.

Type: ConnectApi.CartSummary

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

Get cart items of a specific product.

60.0

60.0

No

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

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.

Type: ConnectApi.ProductCartItem

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

60.0

60.0

No

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

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.

Type: ConnectApi.ProductCartItemCollection

Make a secondary cart a primary cart.

53.0

56.0

Yes

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

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.

Type: ConnectApi.CommerceActionResult

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.

60.0

No

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

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.

Type: ConnectApi.PreserveCart

Set the visibility for cart messages.

50.0

54.0

No

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

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

A ConnectApi.CartMessagesVisibilityInput object specifying the visibility setting.

Type: ConnectApi.CartMessagesVisibilityResult

Update an item in a cart.

49.0

54.0

No

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

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

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

Type: ConnectApi.CartItem

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.

Update an item in a cart of a specific currency.

57.0

57.0

No

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

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

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

currencyIsoCode

Type: String

The currency ISO code of the cart.

Type: ConnectApi.CartItem

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.

Update an item in a cart of a specific currency.

64.0

51.0

No

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

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

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.

Type: ConnectApi.CartItem

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.

Create or update an inventory reservation.

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

58.0

No

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

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

A ConnectApi.CartInventoryReservationInputRepresentation input class indicating the reservation duration.

Type: ConnectApi.CartInventoryReservationOutputRepresentation