---
schema_version: "1"
id: a40ea17e999057fd59e94ba1638e343b945fd0d58bf587c4a9a14666cc03ebeb
title: Cancel Cart Items
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/industries/cme/guides/comms-cancel-cart-items.md
canonical_url: https://developer.salesforce.com/docs/industries/cme/guide/comms-cancel-cart-items.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: b4baaf2a4632485a0f319c9ad42985e1654a2e93740a9d14cc240d3f9eea3b8a
products:
  - Communications, Media, Energy and Utilities APIs (Managed Package)
  - Industries Developer Documentation
---
# Cancel Cart Items

In a supplemental order, this API provides the ability to cancel a line item. When you cancel a line item, you are cancelling the change that is represented by that line item.

This lists includes several examples:

- When the action for the line item action is Add, then the user’s intent in the original order was to add a new asset to the account. Cancelling that action in a supplemental order means the new asset is not added.

- When the action for the line item action is Change, the user’s intent in the original order was to make changes to an asset through the MACD Asset-based Order Item record. Cancelling that action in a supplemental order implies the user did not want to make the change. So, the asset configuration does not change.

- When the action for the line item action is Disconnect, the user’s intent in the original order was to disconnect the asset. Cancelling that action in a supplemental order implies the user no longer wants to disconnect the asset, so, the asset is not disconnected through the supplemental order.

- When the action for the line item action is Existing, the user’s intent in the original order was to make changes to a related line item that was pulled in from the Account. Cancelling that action in a supplemental order means you are not making any changes to that particular line item.

## REST

Not available. There is no REST endpoint for this API.

## How to Invoke this API

To invoke this API, use the following APEX method:

```nolang
/**
* This method can be used to create a followOn order.
* Inputs:
* orderId - Id. The original order's Id.
**/
public static void createFollowOnOrder(Id orderId)
{
    final String methodName = 'cancelCartItems';
    Map<String, Object> inputMap = new Map<String, Object>
    {
        'cartId' => orderId,
        'itemIds' => new List<Id> { 'rootItemId' },
        'methodName' => methodName
    };
    Map<String, Object> outputMap = new Map<String, Object>();
    Map<String, Object> optionsMap = new Map<String, Object>();
    vlocity_cmt.CpqAppHandler handler = new vlocity_cmt.CpqAppHandler();
    handler.invokeMethod(methodName, inputMap, outputMap, optionsMap);
    // traverse the result that was returned, to find the followOn order id.
    vlocity_cmt.JSONResult result = (vlocity_cmt.JSONResult) outputMap.get('result');
}
```

## Example 1 - Create an Amend Order

CPQ uses this flow to create an Amend order.

![](https://developer.salesforce.com/docs/media/cartapi_amendorder.png)

## Example 2 - Create a Cancel Order

CPQ uses this flow to create a Cancel order.

![](https://developer.salesforce.com/docs/media/cartapi_cancelorder.png)

## Example 3 - Discard a Supplemental Order

To discard the supplemental order, set the supplemental order’s `OrderStatus__c = Discarded`.
