# Carts and Orders overview Overview of the concepts related to Carts, Orders, and the overall checkout process. Learn more about how to implement a custom checkout flow in our self-paced Implement a custom checkout module. ## General concepts This section covers key concepts and structures that apply to both Carts and Orders. Understanding these fundamentals is essential for effectively managing the checkout process and related resources. ### Line Items A [Line Item](https://docs.commercetools.com/api/projects/carts.md#lineitem) is a snapshot of a [Product Variant](https://docs.commercetools.com/api/projects/products.md#productvariant) at the time it is added to a Cart. The snapshot of a Product Variant is created from the [ProductProjection](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3AProductProjection) as follows: - The [current projection](https://docs.commercetools.com/api/projects/productProjections.md#current--staged) is used. - Product Attributes are merged with Variant Attributes to ensure the full Attribute context of the [ProductProjection](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3AProductProjection). - If the Cart is bound to a [Store](https://docs.commercetools.com/api/projects/stores.md), the following additional checks and projections are performed: - For Stores with active [Product Selections](https://docs.commercetools.com/api/projects/product-selections.md), the selected Product Variant must be included in at least one of the active Product Selections. - The selected Product Variant must be [available in a Store](https://docs.commercetools.com/api/project-configuration-overview.md#products-available-in-store). - All [LocalizedStrings](https://docs.commercetools.com/api/types.md#localizedstring) are [filtered](https://docs.commercetools.com/api/projects/productProjections.md#locales) by the locales defined in the Store. If the API cannot find a matching locale in the Store languages, the first locale found in the [Project](https://docs.commercetools.com/api/projects/project.md) settings is used as a fallback. - All [Prices](https://docs.commercetools.com/api/types.md#price) are [filtered](https://docs.commercetools.com/api/projects/productProjections.md#prices) according to the Product distribution Channels defined in the Store. Prices without a Channel are also included. - All [ProductVariantAvailabilities](https://docs.commercetools.com/api/projects/products.md#productvariantavailability) are [filtered](https://docs.commercetools.com/api/projects/productProjections.md#inventory-entries) according to the Inventory supply Channel defined in the Store. Inventory entries without a Channel are also included. If the Product Variant changes, the relation to the current [ProductProjection](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3AProductProjection) is kept, but the Line Item is not updated automatically. The Line Item can be [updated](https://docs.commercetools.com/api/projects/carts.md#recalculate) through the Carts API on demand. With this update, the Product Variant data is copied to the `variant` field of the [LineItem](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3ALineItem). Carts containing Line Items that reference deleted Product Variants cannot be used to create Orders. ### Custom Line Items A [Custom Line Item](https://docs.commercetools.com/api/projects/carts.md#customlineitem) is a generic item not associated with a Product Variant. It can be used for selling services or virtual goods that do not require inventory tracking, such as additional fees or vouchers. You add Custom Line Items to a Cart in the same way as [Line Items](https://docs.commercetools.com/api/carts-orders-overview.md#line-items). However, [Line Item price selection](https://docs.commercetools.com/api/pricing-and-discounts-overview.md#line-item-price-selection) doesn't apply to Custom Line Items; instead, you control the price and taxes of the item. The monetary value of a Custom Line Item can be negative; therefore, it can be used for discounts applied by vouchers. Furthermore, Custom Line Items can be used to implement more complex cart logic through [Cart Predicates](https://docs.commercetools.com/api/projects/predicates.md#cart-predicates). The [InventoryMode](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3AInventoryMode) of a Cart has no effect on Custom Line Items. ### Store-specific and global Customers If a Customer is assigned to one or more [Stores](https://docs.commercetools.com/api/project-configuration-overview.md#store), they are considered a Store-specific Customer. Store-specific Customers can only be associated with Carts and Orders in their assigned Stores. In contrast, global Customers are not assigned to any Stores and can be associated with Carts and Orders either in specific Stores, or without a Store. For more information, see [Global versus Store-specific Customers](https://docs.commercetools.com/api/customers-overview.md#global-versus-store-specific-customers). ### Guest checkout To offer checkout functionality without requiring a visitor to sign in or create an account, you can create an [anonymous session](https://docs.commercetools.com/api/authorization.md#tokens-for-anonymous-sessions). When you create a Cart, Shopping List, or Payment, you can set an `anonymousId` on the resource to link it to the anonymous session. It is good practice to create an anonymous session only once the visitor begins interacting with the Cart, for example, by adding an item to it. This avoids creating a large number of unused sessions. For more information, see [Manage token requests](https://docs.commercetools.com/api/authorization/#create-anonymous-sessions-only-once-necessary). Carts with an `anonymousId` are known as anonymous Carts. If you create an Order from an anonymous Cart, the Order is automatically assigned the same `anonymousId`. If the visitor [signs in to an existing account](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Flogin%3APOST), or [creates a new account](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Fcustomers%3APOST), you can link a single anonymous Cart, or link all of their existing anonymous resources ([Carts](https://docs.commercetools.com/api/projects/carts.md#set-customer-id), [Orders](https://docs.commercetools.com/api/projects/orders.md#set-customer-id), [Shopping Lists](https://docs.commercetools.com/api/projects/shoppingLists.md#set-customer), and [Payments](https://docs.commercetools.com/api/projects/payments.md#set-customer)) to the Customer. A visitor can have multiple active Carts associated with their account, but they aren't signed in. In this case, if the visitor starts shopping with an anonymous Cart and later signs in to their account, the default behavior is to attempt to merge the items into their most recently modified active Cart, in a process called a [Cart merge](https://docs.commercetools.com/api/carts-orders-overview.md#merge-a-cart). For more information about transferring resources to a Customer during sign-up or sign-in, see [Customer authentication](https://docs.commercetools.com/api/customers-overview.md#customer-authentication-sign-in). ## Carts Carts hold [Product Variants](https://docs.commercetools.com/api/projects/products.md#productvariant) that are referred to as [Line Items](https://docs.commercetools.com/api/carts-orders-overview.md#line-items) once added to the Cart, and [Custom Line Items](https://docs.commercetools.com/api/carts-orders-overview.md#custom-line-items). During checkout, a Cart is [ordered](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Forders%3APOST). The status of a Cart is defined by its [CartState](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3ACartState). Carts that can be updated and ordered have the [CartState](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3ACartState) `Active` and are known as active Carts: - Customers can have more than one active Cart. - To retrieve the most recently modified active Cart, use [Get Cart](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Fcarts%2F%7Bid%7D%3AGET), [Get Cart in Store](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Fin-store%2Fkey%3D%7BstoreKey%7D%2Fcarts%2F%7Bid%7D%3AGET), or [Get Cart in Business Unit](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Fas-associate%2F%7BassociateId%7D%2Fin-business-unit%2Fkey%3D%7BbusinessUnitKey%7D%2Fcarts%2F%7Bid%7D%3AGET) - To retrieve all active Carts for a Customer, use [Query Carts](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Fcarts%3AGET), [Query Carts in Store](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Fin-store%2Fkey%3D%7BstoreKey%7D%2Fcarts%3AGET), or [Query Carts in Business Unit](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Fas-associate%2F%7BassociateId%7D%2Fin-business-unit%2Fkey%3D%7BbusinessUnitKey%7D%2Fcarts%3AGET) with a [query predicate](https://docs.commercetools.com/api/predicates/query.md) that targets both the Customer and `cartState`. ### Create a Cart To create a Cart, you can use the following endpoints: - [Create Cart](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Fcarts%3APOST), [Create Cart in Store](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Fin-store%2Fkey%3D%7BstoreKey%7D%2Fcarts%3APOST), and [Create Cart in Business Unit](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Fas-associate%2F%7BassociateId%7D%2Fin-business-unit%2Fkey%3D%7BbusinessUnitKey%7D%2Fcarts%3APOST) : creates a new Cart. You can specify the Line Items and Custom Line Items to add to the Cart during its creation. - [Replicate Cart](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Fcarts%2Freplicate%3APOST), [Replicate Cart in Store](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Fin-store%2Fkey%3D%7BstoreKey%7D%2Fcarts%2Freplicate%3APOST), and [Replicate Cart in Business Unit](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Fas-associate%2F%7BassociateId%7D%2Fin-business-unit%2Fkey%3D%7BbusinessUnitKey%7D%2Fcarts%2Freplicate%3APOST) : creates a new Cart by replicating an existing Cart or Order. This can be useful if a customer wants to cancel a recent order to make changes or reorder a previous order. ### Update a Cart To update a Cart, you can use the [Update Cart](https://docs.commercetools.com/api/projects/carts.md#update-cart), [Update Cart in Store](https://docs.commercetools.com/api/projects/carts.md#update-cart-in-store), or [Update Cart in Business Unit](https://docs.commercetools.com/api/projects/associate-carts.md#update-cart-in-businessunit-as-associate) endpoints along with one or more [update actions](https://docs.commercetools.com/api/projects/carts.md#update-actions). After all update actions are performed, the Cart: - removes any Line Items that are invalid due to deleted Products, Product Variants, or Prices. - removes any Line Items that are invalid due to an inactive [StandalonePrice](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3AStandalonePrice). When a Product is unpublished, any associated Line Items already present in a Cart remain unaffected and can still be ordered. To prevent this, do the following: - If the Product uses Embedded Prices, [remove them](https://docs.commercetools.com/api/projects/products.md#remove-price) from the unpublished Product. - If the Product uses Standalone Prices, [deactivate](https://docs.commercetools.com/api/projects/standalone-prices.md#change-active) or [delete](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Fstandalone-prices%2F%7Bid%7D%3ADELETE) the Standalone Prices. - removes any Line Items with quantities that are outside the limits specified in their associated [InventoryEntries](https://docs.commercetools.com/api/projects/inventory.md#inventoryentry). - updates any [LineItem](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3ALineItem) `price` field if the result of the [Line Item price selection](https://docs.commercetools.com/api/pricing-and-discounts-overview.md#line-item-price-selection) has changed because of a Product update. - updates the [ShippingInfo](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3AShippingInfo), in particular, the `price` and `shippingMethodState` fields. - updates the discounts, which may affect the [LineItem](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3ALineItem) or [CustomLineItem](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3ACustomLineItem) `totalPrice` fields and [ShippingInfo](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3AShippingInfo) `discountedPrice` field: - if a [Cart Discount](https://docs.commercetools.com/api/projects/cartDiscounts.md) becomes invalid due to deactivation, expiration, or the predicate no longer matches the Cart's content, the discount is removed. - if a Cart Discount becomes active and applicable (since the last update), the discount is added. - if a [Discount Code](https://docs.commercetools.com/api/projects/discountCodes.md) becomes invalid due to usage limits, deactivation, expiration, or the predicate no longer matches the Cart's content, the discount is removed. - updates the [Cart](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3ACart) `totalPrice` field. - updates the Tax Rates, in particular, the `taxedPrice` field. - updates the [LineItem](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3ALineItem) `productKey`. To perform the above-mentioned updates without additional update actions, send a request with only the [Recalculate](https://docs.commercetools.com/api/projects/carts.md#recalculate) update action. To update the Product data saved in the Line Items, use the [Recalculate](https://docs.commercetools.com/api/projects/carts.md#recalculate) update action with `updateProductData` set to `true`. ### Freeze a Cart To prevent a Cart from being modified by changes to prices and, in specific cases, discounts, you can [freeze](https://docs.commercetools.com/api/projects/carts.md#freeze-cart) it. This is useful during checkout to ensure the customer pays the price seen in their cart, even if prices or promotions change before order placement. When freezing a Cart, you specify a [FreezeStrategy](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3AFreezeStrategy): `SoftFreeze` or `HardFreeze`. The following behavior applies to frozen Carts with the `SoftFreeze` strategy: - Prices remain as they were when the Cart was frozen. However, if a Price that a Line Item depends on is deleted entirely, the affected Line Item is removed from the frozen Cart. - Update actions as well as background services modifying prices on the Cart are deactivated for frozen Carts. - Inventory is not reserved for Line Items in frozen Carts. - Frozen Carts can be [ordered](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Forders%3APOST) or [unfrozen](https://docs.commercetools.com/api/projects/carts.md#unfreeze-cart). When unfrozen, a Cart continues to accept new updates. The `HardFreeze` strategy includes all the `SoftFreeze` behavior listed above, plus the following additional restrictions: - Discounts and Discount Codes remain as they were when the Cart was frozen. - Shipping method updates are not allowed. #### Impact of changes on frozen Carts (a CSV formatted table follows. The first line are the column names.) Resource,Change,`SoftFreeze` behavior,`HardFreeze` behavior Prices,Updated,Ignored. The frozen Cart retains the price at the time of freezing.,Same as `SoftFreeze` ,Deleted,The Line Item that uses the deleted price is removed from the frozen Cart.,Same as `SoftFreeze` Cart Discounts,Created,Ignored. New Cart Discounts are not applied.,Same as `SoftFreeze` ,Activated,Ignored. Cart Discounts that become active are not applied.,Same as `SoftFreeze` ,Expired,Remain applied as they were at the time of freezing.,Same as `SoftFreeze` ,Inactivated,Removed from the frozen Cart.,Remain applied as they were at the time of freezing. ,Deleted,Removed from the frozen Cart.,Remain applied as they were at the time of freezing. ,Invalidated (due to Cart predicates not matching),Removed from the frozen Cart.,Remain applied as they were at the time of freezing. Product Discounts,Created,Ignored. New product discounts are not applied.,Same as `SoftFreeze` ,Expired,Remain applied as they were at the time of freezing.,Same as `SoftFreeze` ,Inactivated,Remain applied as they were at the time of freezing.,Same as `SoftFreeze` ,Deleted,Remain applied as they were at the time of freezing.,Same as `SoftFreeze` Discount Codes,Created,Can be added. If the Discount Code predicate does not match the Cart, the `state` changes to `DoesNotMatchCart` and doesn't change the Cart total.,Cannot be added. ,Removed (from Cart),Can be removed, and the Cart total is updated.,Cannot be removed. ,Invalidated (due to Cart predicates not matching),Discount Code remains in the Cart, the `state` changes to `DoesNotMatchCart`, and the Cart total is updated. If later, the Discount Code becomes valid, it will not automatically re-apply.,Remain applied as they were at the time of freezing (predicate is not re-evaluated). ,Inactivated,Discount Code remains in the Cart, the `state` changes to `NotActive` and the discount is removed, updating the Cart total.,Remain applied as they were at the time of freezing. ,Deleted (from Project),Discount Code remains in the Cart with the last known status (for example: `NotActive`), but no longer affects the Cart total.,Remain applied as they were at the time of freezing. Direct Discounts,Set (on Cart),Added to the cart, but not applied.,Cannot be set. ,Removed (from Cart),Can be removed, and the Cart total is updated.,Cannot be removed. Other,Updates that affect the price of Cart items,Not accepted. Maintains price stability of the Line Items and Custom Line Items. To view the list of price-related updated actions that are not allowed, see the `frozen` [CartState](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3ACartState).,Same as `SoftFreeze` ,Updates that do not affect the price of Cart items,Accepted, and the Cart total is updated accordingly. Setting shipping methods is permitted even though it can affect the price.,Setting shipping methods is not allowed. ,Inventory quantity limit updates,During order creation: if line item quantities fall outside the new limits, order creation will fail.When unfrozen: line items violating the new limits will be removed.,Same as `SoftFreeze` ,Anonymous user signs in or signs up,The frozen Cart is not [merged](https://docs.commercetools.com/api/customers-overview.md#cart-merge-during-sign-in-and-sign-up).,Same as `SoftFreeze` ,The Shipping Method on the Cart is not active,Order creation is rejected.,Same as `SoftFreeze` ,A global Shipping Method on the Cart is replaced with a Store-scoped Shipping Method,Store validations for the Shipping Method are bypassed, and the Order is created.,Same as `SoftFreeze` ,A Store-scoped Shipping Method on the Cart is associated with a different Store,Store validations for the Shipping Method are bypassed, and the Order is created.,Same as `SoftFreeze` When applying update actions, the API still performs validations on the Cart to ensure that it is convertible to an [Order](https://docs.commercetools.com/api/projects/orders.md), and reports errors if such a validation fails. Creating an Order will fail if the frozen Cart contains a Discount that must be removed (according to the previously mentioned restrictions), or if a Tax Rate for one or more items has changed. ### Lock a Cart To prevent all updates to a Cart, you can [lock](https://docs.commercetools.com/api/projects/carts.md#lock-cart) it. Locking is distinct from [freezing](https://docs.commercetools.com/api/carts-orders-overview.md#freeze-a-cart), which only blocks updates that affect the Cart's total price. Use locking for assisted selling scenarios where a support agent needs exclusive access to a Cart while they perform updates. The Cart's `lock` [field](https://docs.commercetools.com/api/projects/carts.md#cart) is set when the Cart is locked. A [CartLock](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3ACartLock) records which API Client locked the Cart and when. Only API Clients with the `manage_locked_carts` [OAuth 2.0 Scope](https://docs.commercetools.com/api/scopes.md) can do the following: - [Lock](https://docs.commercetools.com/api/projects/carts.md#lock-cart) a Cart. - Update a locked Cart. - [Unlock](https://docs.commercetools.com/api/projects/carts.md#unlock-cart) a Cart. ### Merge a Cart When a visitor starts shopping while signed out, you create an [anonymous Cart](https://docs.commercetools.com/api/carts-orders-overview.md#guest-checkout) to hold their items. If they later sign in to an account that already has an active Cart, you can merge the anonymous Cart into the existing active Cart. This ensures that they don't lose their selected items. You can trigger this merge automatically during sign-up or sign-in, or manually at any other time. After a Cart merge, the resulting Cart depends on the selected merge mode. Depending on the scenario, the anonymous Cart may become the new active Cart, or its contents may be merged into the existing active Cart. Carts that are no longer active are not deleted and remain available for inspection, but may be read-only depending on their [CartState](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3ACartState). To be eligible for a Cart merge, the anonymous Cart and the Customer's active Cart must use the same currency (identified through `totalPrice.currency`). Furthermore, if a [Store](https://docs.commercetools.com/api/projects/stores.md) or [Business Unit](https://docs.commercetools.com/api/projects/business-units.md) is assigned to either Cart, it must match across both Carts. (a CSV formatted table follows. The first line are the column names.) Merge method,Use for,API,Endpoints Automatic Cart merge during sign-up or sign-in,Customers authenticating through the [Internal OAuth](https://docs.commercetools.com/api/authorization.md#request-an-access-token-using-the-internal-oauth-20-service).,Customers API,All [sign-up](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Fcustomers%3APOST) and [sign-in](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Flogin%3APOST) endpoints. See the [Customers overview](https://docs.commercetools.com/api/customers-overview.md#cart-merge-during-sign-in-and-sign-up) page for more information. Manual Cart merge,Customers authenticating through the [Internal OAuth](https://docs.commercetools.com/api/authorization.md#request-an-access-token-using-the-internal-oauth-20-service) or an [external OAuth server](https://docs.commercetools.com/api/authorization.md#request-an-access-token-using-an-external-oauth-server).,Carts API,[Merge Cart](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Fcarts%2Fcustomer-id%3D%7BcustomerId%7D%2Fmerge%3APOST), [Merge Cart in Store](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Fin-store%2Fkey%3D%7BstoreKey%7D%2Fcarts%2Fcustomer-id%3D%7BcustomerId%7D%2Fmerge%3APOST) #### Merge modes The merge mode determines how an anonymous Cart and a Customer's active Cart are combined during a merge operation: - For automatic Cart merge during sign-up or sign-in, use [AnonymousCartSignInMode](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3AAnonymousCartSignInMode). - For manual Cart merge, use [CartMergeMode](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3ACartMergeMode). Both types have identical enum values and merging behavior. When multiple active Carts are associated with a Customer, the most recently modified active Cart is selected for the merge operation. ##### MergeWithExistingCustomerCart The following behavior describes the `MergeWithExistingCustomerCart` merge mode: (a CSV formatted table follows. The first line are the column names.) Scenario,What happens,Tax recalculation Customer has no active Cart,Anonymous Cart becomes the active Cart,Yes, normal tax/price recalculation when the new Cart becomes active Customer has an active Cart without a shipping address,Items from anonymous Cart are merged into the existing active Cart according to the [merge rules](https://docs.commercetools.com/api/carts-orders-overview.md#merge-rules).,No Customer has an active Cart with a shipping address,Items from anonymous Cart are merged into the existing active Cart according to the [merge rules](https://docs.commercetools.com/api/carts-orders-overview.md#merge-rules).,Yes, tax rates are recalculated based on the active Cart’s shipping address, even if the anonymous Cart doesn't have one ##### UseAsNewActiveCustomerCart The following behavior describes the `UseAsNewActiveCustomerCart` merge mode. (a CSV formatted table follows. The first line are the column names.) Scenario,What happens,Tax recalculation Customer has no active Cart,Anonymous Cart becomes the active Cart,Yes, price/tax recalculation occurs when it becomes the active Cart Customer has an active Cart without a shipping address,Anonymous Cart becomes the active Cart,No Customer has an active Cart with a shipping address,Anonymous Cart becomes the active Cart,Yes, but only if the anonymous Cart does not have its own shipping address #### Merge rules When merging an anonymous Cart and a Customer’s active Cart, the system follows specific rules to determine how to combine the items. The goal is to ensure that the resulting Cart accurately reflects the Customer's intended purchases without duplicating items unnecessarily. The merge process follows these steps: 1. Key conflict check: The system checks whether any Line Items and Custom Line Items in the anonymous Cart share the same `key` as items in the Customer’s Cart but refer to different products or variants. If a key conflict is detected, the conflicting items from the anonymous Cart are skipped and not considered further. These items are not added to the merge result and remain only in the anonymous Cart. 2. Property-based matching: For all remaining Line Items and Custom Line Items, the system determines whether items from the anonymous Cart match items in the Customer’s Cart. To do this, it compares specific properties of the items, as detailed in the table below. All properties listed for each item type must match exactly for the items to be considered identical. Keys are not considered in the property-based matching logic. Two items are considered identical if the following properties match, even if their keys differ or if one item has no key. (a CSV formatted table follows. The first line are the column names.) Item type,Properties compared Line Items,`productId`, `variantId`, `supplyChannel`, `distributionChannel`, `custom`, `priceMode` Custom Line Items,`name`, `slug`, `money`, `taxCategory`, `custom` 3. Merging behavior: The system processes each item from the anonymous Cart based on the results of the property-based matching. - If an anonymous Cart item matches an existing Customer Cart item: - The items are merged. The resulting item uses the higher of the two quantities. - The `itemShippingAddresses` from both items are merged into the Customer Cart. - If an anonymous Cart item does not match an existing Customer Cart item, it is added as a separate item with its original quantity. For Carts with `Multiple` `ShippingMode`, the `shipping` arrays from both Carts are merged. A `Shipping` entry is only retained if its `shippingKey` is still referenced by an item. After the merge is complete, the anonymous Cart retains its original content, and its `cartState` is updated to `Merged`. Although this [CartState](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3ACartState) prevents any further modifications to the Cart, you can use the Cart to check for any items that could not be merged. ### Lifetime The lifetime of a [Cart](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3ACart) is controlled by the `deleteDaysAfterLastModification` property and can be adjusted according to your requirements. If unspecified, during Cart creation, the `deleteDaysAfterLastModification` property is copied from the Project's [Carts configuration](https://docs.commercetools.com/api/projects/project.md#cartsconfiguration). Changing the Project's Carts configuration does not affect existing Carts. For details about automatic cleanup behavior and defaults, see [Cleanup of old data](https://docs.commercetools.com/api/general-concepts.md#cleanup-of-old-data). During this lifetime, a Cart is kept as it was the last time when actions were performed on it. It contains Line Items and Custom Line Items with prices that were valid at the time of the last Cart update and [Cart Discounts](https://docs.commercetools.com/api/projects/cartDiscounts.md) that were active at that time. Any read method on a Cart alone will not lead to a representation with up-to-date prices and so on, only Cart updates will trigger this. ### Price precision - Prices with [TypedMoney](https://docs.commercetools.com/api/types.md#typedmoney) can be cent-precision or high-precision. - When calculating net and gross prices, prices with decimals are rounded. If the fraction of `centAmount` is exactly 0.5, the [RoundingMode](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3ARoundingMode) defined by `taxRoundingMode` is applied to the Cart's price. - If the tax is not included in the price (`includedInPrice=false` on the [TaxRate](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3ATaxRate)), the tax portions are derived from the net prices. If the tax is included in the price (`includedInPrice=true` on the [TaxRate](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3ATaxRate)), then the tax portions are derived from the gross prices. This only applies when the `Platform` [TaxMode](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3ATaxMode) is used. - If tax is included in the Line Item price (`includedInPrice=true` on the [TaxRate](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3ATaxRate)), the (discounted) price multiplied by the quantity applies to the gross price of a Line Item. If `includedInPrice=false`, the (discounted) price multiplied by the quantity applies to the net price of a Line Item. If a Line Item's prices are of [HighPrecisionMoney](https://docs.commercetools.com/api/types.md#highprecisionmoney), `priceRoundingMode` is used for rounding the calculations. - When prices are discounted with [relative discounts](https://docs.commercetools.com/api/projects/cartDiscounts.md#cartdiscountvaluerelative), they are always rounded in favor of the customer with [half-down rounding](https://en.wikipedia.org/wiki/Rounding#Rounding_half_down). #### Cash or denomination rounding In some countries, prices must be rounded to the nearest 5 or 10 units since smaller coin denominations have been withdrawn from circulation. For example: - In Hungary, offline cash payments are rounded to the nearest 5 forints while online prices can use any amount. - In Switzerland, both offline and online prices are rounded to the nearest 5 centimes. Amounts ending in 1, 2, 6, or 7 round down, and amounts ending in 3, 4, 8, or 9 round up—for example, CHF 10.42 is rounded to CHF 10.40 and CHF 10.43 is rounded to CHF 10.45. Cash rounding is not the same as the [RoundingMode](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3ARoundingMode) set by `priceRoundingMode` and `taxRoundingMode` on a Cart. Those control how decimal midpoints in calculated values are resolved; cash rounding rounds to the nearest currency denomination. To enable cash rounding (for a currency) in your Project, contact the [commercetools support team](https://support.commercetools.com). When enabled, cash rounding is applied to the [Cart](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3ACart) `taxedPrice.totalGross`, or to `totalPrice` if the price does not include taxes. If a price is affected by a Product Discount, the rounding is also reflected in the `discounted` field of prices. Cash rounding is not applied to Cart Discount results. ### Taxes #### Tax rate selection A Cart cannot calculate taxes for the items in it until the `shippingAddress` property is set. The `shippingAddress.country` and `shippingAddress.state` properties affect the selection criteria. These are compared to the `TaxRate`'s `country` and `state` fields. A Tax Rate is only eligible if the `country` and `state` properties are an exact match. Since the `state` field is optional on both `TaxRate` and `shippingAddress`, this means the following: - If `shippingAddress.country` and `TaxRate.country` are an exact match, and no `state` properties are present, the `TaxRate` applies to the Cart. - If `shippingAddress.country` and `TaxRate.country` are an exact match, but only one of `shippingAddress.state` or `TaxRate.state` is present, the Tax Rate does not apply to the Cart. - If `shippingAddress.country` and `TaxRate.country` are an exact match, and `shippingAddress.state` and `TaxRate.state` are an exact match, the Tax Rate applies to the Cart. - If `shippingAddress.country` and `TaxRate.country` are present, and `shippingAddress.state` and `TaxRate.state` are present, but there is a mismatch of either `country` or `state`, the Tax Rate does not apply to the Cart. If you need to include a state or country sub-unit for shipping purposes, use `shippingAddress.region` to avoid Tax Rate conflicts. #### Tax modes By default, newly created Carts use the `Platform` [TaxMode](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3ATaxMode). With this tax mode, the `taxedPrice` of a Cart is calculated automatically based on the Tax Rate that applies for the `country` (and optionally, `state`) of the Cart's `shippingAddress`. The Tax Rate is taken from the [TaxCategory](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3ATaxCategory) assigned to Products and Shipping Methods. If you prefer to have more control over how taxes are calculated in your Project, including the use of an external tax calculation service, you can use one of the following [TaxModes](https://docs.commercetools.com/api/projects/carts.md#taxmode): - `External`: you are responsible for explicitly setting the Tax Rates for Line Items and Custom Line Items. With this tax mode, you must specify whether tax is included in the price for Line Items or Custom Line Items. This mode is suitable when you want commercetools API to handle the tax calculations based on the provided Tax Rates. - `ExternalAmount`: you are responsible for providing the exact tax amounts for Line Items and Custom Line Items, and explicitly setting the `taxedPrice` of the Cart using [Set Cart Total Tax](https://docs.commercetools.com/api/projects/carts.md#set-cart-total-tax). This mode is suitable when you want full control over the tax calculation. For more information about how to set tax amounts, see [ExternalAmount TaxMode](https://docs.commercetools.com/api/projects/carts.md#taxmode). When `includedInPrice: true`, the tax is calculated in a top-down manner, and when `includedInPrice: false`, the tax is calculated in a bottom-up manner. The following example shows the impact of `includedInPrice` in the Cart calculation with `taxRoundingMode: HalfEven` and `taxCalculationMode: LineItemLevel`. (a CSV formatted table follows. The first line are the column names.) Line Item,Product Variant A,Product Variant B,Shipping Line Item: Price,$15,$25,$5 Quantity,10,5,--- External Tax Rate: includedInPrice,false,true,false External Tax Rate: amount,0.19,0.15,0.15 Taxed Item Price: totalNet,$150,$108.70,$5 Taxed Item Price: totalGross,$178.5,$125,$5.75 Calculation formula,15 x 10 (1 + 0.19),25 x 5 / (1 + 0.15),5 x (1 + 0.15) #### Tax calculation mode Due to the principle of rounding on every calculation step, this slight difference in when to apply tax can have a considerable effect on the Cart total. Two tax calculation modes are available to support different use cases: - The `LineItemLevel` [TaxCalculationMode](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3ATaxCalculationMode) enforces tax calculation after multiplying the individual item price by the quantity. - The `UnitPriceLevel` mode calculates the taxed price before multiplying by the quantity. The following example demonstrates the differences in the Cart total depending on the different tax calculation modes. Let's assume: - A tax of 19% is included in the price for all Line Items. - The Cart's [TaxRoundingMode](https://docs.commercetools.com/api/projects/carts.md#roundingmode) is `HalfEven`. - The Cart's [price precision](https://docs.commercetools.com/api/carts-orders-overview.md#price-precision) is two decimals. (a CSV formatted table follows. The first line are the column names.) Line Item #,Quantity,Unit Price,Line Item Total, Net(`LineItemLevel`),Line Item Total, Net(`UnitPriceLevel`),Line Item Total, Gross 1,1,$1.00,$0.84,$0.84,$1.00 2,10,$1.08,$9.08,$9.10,$10.80 3,10,$108.08,$908.24,$908.20,$1080.80 4,1,$2.00,$1.68,$1.68,$2.00 5,50,$0.01,$0.42,$0.50,$0.50 6,1,$4.90,$4.12,$4.12,$4.90 ,,,Cart Total, Net(`LineItemLevel`),Cart Total, Net(`UnitPriceLevel`),Cart Total, Gross ,,,$924.38,$924.44,$1100.00 As seen from the example, if a Line Item has a quantity of 1, the two modes have no impact on the total net value of a Line Item (see Line Item #1, 4, and 6). However, if the quantity is more than 1, the two modes calculate the total net value of a Line Item with a difference of several cents (see Line Item #2, 3, and 5). Depending on the specific Line Item values, the chosen mode can give a greater or lesser net value (see Line Item #2 compared to #3). A difference of 6 cents is accumulated in the Cart total. The connection to rounding is especially clear with Line Item #5. Due to rounding after applying tax to 0.01 and multiplying by quantity 50 upon that, the net value when using `UnitPriceLevel` ends up being equal to the gross value. With `LineItemLevel`, where quantity multiplication is performed as a first calculation step, the rounding occurs to a greater value, and the net value ends up being $0.42. ### Inventory For details on managing inventory, including information about inventory modes, quantity enforcement, and consistency guarantees, see the [Inventory overview](https://docs.commercetools.com/api/inventory-overview.md). ## Orders An Order is a snapshot of a transaction between a customer and a business. It serves as a durable record of the transaction and includes details such as the selected items, pricing, customer information, shipping and billing addresses, selected shipping methods, payment information, and order state. While it does not inherently manage the full post-purchase lifecycle (such as fulfillment, returns, or refunds), it acts as the foundation upon which those processes can be built or integrated. ### Create an Order To create an Order, you use one of the following methods: from a Cart, from a Quote, or by using Order Import. #### From a Cart This is the most common method for creating an Order, used for typical customer purchases during checkout. The following information is copied to the Order: - Line Items and Custom Line Items (with prices and any associated Custom Fields) - Shipping and billing addresses - Customer information - Custom Fields (Cart-level) - Selected Shipping Method - Payment information - Discount Codes - Direct Discounts - Tax settings - Inventory Mode - Origin - Refused Gift Line Items - Cart reference - Any associated Store or Business Unit For more information, see the [Create Order from Cart](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Forders%3APOST), [Create Order in Store from Cart](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Fin-store%2Fkey%3D%7BstoreKey%7D%2Forders%3APOST), and [Create Order from Cart in Business Unit](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Fas-associate%2F%7BassociateId%7D%2Fin-business-unit%2Fkey%3D%7BbusinessUnitKey%7D%2Forders%3APOST) endpoints. #### From a Quote This method creates an Order based on the agreed-upon terms of a [Quote](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3AQuote) and is commonly used in B2B scenarios or when price negotiations are required. The Order includes the negotiated prices, quantities, and any other specific conditions outlined in the Quote. The Quote transitions through different [states](https://docs.commercetools.com/api/projects/quotes.md#quotestate) during the negotiation process. To create an Order from a Quote, the Quote must have the `Pending` state. For more information, see the [Quotes overview](https://docs.commercetools.com/api/quotes-overview.md) and the [Create Order from Quote](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Forders%2Fquotes%3APOST), [Create Order in Store from Quote](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Fin-store%2Fkey%3D%7BstoreKey%7D%2Forders%2Fquotes%3APOST), and [Create Order from Quote in Business Unit](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Fas-associate%2F%7BassociateId%7D%2Fin-business-unit%2Fkey%3D%7BbusinessUnitKey%7D%2Forders%2Fquotes%3APOST) endpoints. #### Using Order Import This method lets you import existing Orders from external systems or other Projects. This is useful when you need to migrate from a legacy system or consolidate Orders from different sources. Order Import requires that you provide all necessary Order data in a specific format. This data must adhere to the Order model. For more information, see the [Create Order by Import](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Forders%2Fimport%3APOST) endpoint. ### Update an Order An Order is a legally binding purchase agreement between the Merchant and the customer; therefore, changes to it should be carefully considered. To update the [Order](https://docs.commercetools.com/api/projects/orders.md), you have two options: [direct updates](https://docs.commercetools.com/api/projects/orders.md#update-actions) or [Order Edits](https://docs.commercetools.com/api/projects/order-edits.md). The option you choose depends on whether a financial change to the purchase agreement is required. If, for instance, a customer provides an incorrect shipping address by mistake, a change is required to ensure the goods can be delivered to the customer. A [direct update](https://docs.commercetools.com/api/projects/orders.md#update-actions) action is available to change the shipping address for such cases. However, if the proposed change to the shipping address results in changes to the applicable taxes of the Order items, a direct update to the Order is not possible. In this case, because a financial change will occur, you must use an [Order Edit](https://docs.commercetools.com/api/projects/order-edits.md) instead, which ensures the amendment is traceable for audit purposes. To learn about which update actions are available for each method, see [Overview of update actions for Cart, Order, and Order Edit](https://docs.commercetools.com/api/carts-orders-overview.md#overview-of-update-actions-for-cart-order-and-order-edit). #### Non-financial changes Use the [Order update actions](https://docs.commercetools.com/api/projects/orders.md#update-actions) to directly modify an [Order](https://docs.commercetools.com/api/projects/orders.md) when no financial change occurs. For example, changes to: - Order number, State, or locale - Customer's email address or billing address - Shipping information, such as addresses, that do not require recalculation of the Shipping Method and shipping rates - Payment information - Deliveries and returns - Any other change that does not affect the Order total #### Financial changes Use [Order Edits](https://docs.commercetools.com/api/projects/order-edits.md) when you need to update an [Order](https://docs.commercetools.com/api/projects/orders.md) that results in a financial change. For example, changes to: - Line Items and Custom Line Items (such as quantity) - Shipping information, such as addresses, that require recalculation of the Shipping Method and shipping rates - Discounts - Any other change that affects the Order total In addition to any updates that financially impact the Order, you can also update non-financial properties within the same Order Edit. For example, you can update a Customer's email address alongside any changes that affect the total price of the Order. The Order Edits API does not support tracking or reserving inventory. You can only create an Order Edit if the [InventoryMode](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3AInventoryMode) of the Order and its [LineItems](https://docs.commercetools.com/api/projects/carts.md#lineitem) is `None`. Shipping addresses, including country and state, are used to identify applicable [Shipping Methods](https://docs.commercetools.com/api/projects/shippingMethods.md) and shipping rates for an Order. You can update shipping addresses using direct updates or Order Edits, however, reevaluation of Shipping Methods and shipping rates is only triggered when changes are initiated through an Order Edit. ##### Intended flow The basic flow for an Order Edit: 1. Create an OrderEdit: use the [Create OrderEdit](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Forders%2Fedits%3APOST) endpoint to create an OrderEdit entity. Upon creation, the OrderEdit contains a reference to the target Order within the `resource` field; however, no data is copied between the entities. At this point, you can consider the OrderEdit to be a staging area to collect the proposed changes. 2. Add the proposed changes: use the [Update OrderEdit by ID](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Forders%2Fedits%2F%7Bid%7D%3APOST) endpoint to add the individual [update actions](https://docs.commercetools.com/api/projects/orders.md#update-actions) to the OrderEdit. Immediately upon adding the update actions to the OrderEdit, the `stagedActions` are run against the Order; a so-called dry run. As a response, the Order is returned as if the Order actions had been applied. This allows you to preview the changes and understand the impact on the total price of the Order. The response will also contain Messages which capture the changes applied to the Order. Dry runs are always performed against the latest version of the Order. If the Order endpoint contains [API Extensions](https://docs.commercetools.com/api/projects/api-extensions.md), they are also called during the dry run. 3. Review the preview: ensure a careful review of the preview takes place, as the Order always respects the current product catalog, price configuration, and promotions. For example, if an OrderEdit is made soon after Order placement, changes will likely be minimal. However, if more time has passed, price adjustments and expired promotions may significantly impact the Order. We recommend that you review the Messages within the preview to understand the proposed changes. For example, the [OrderEditApplied](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3AOrderEditApplied) Message details the before and after values of the net total, gross total, and tax portion. 4. Apply the changes: use the [Apply OrderEdit](https://docs.commercetools.com/api/projects/order-edits.md#apply-orderedit) endpoint to apply your proposed changes to the original Order. When you [apply an Order Edit](https://docs.commercetools.com/api/projects/order-edits.md#apply-orderedit), the Order is recalculated using the same criteria listed under [Update a Cart](https://docs.commercetools.com/api/carts-orders-overview.md#update-a-cart). During recalculation, Discounts that have become invalid or are otherwise no longer applicable are removed. Only Discounts that are valid at the time of the Order Edit application are applied to the updated Order. The Order (not the OrderEdit) triggers the [OrderEditApplied](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Atype%3AOrderEditApplied) Message, which contains both the original and the newly applied values. At this point, you can delete the Order Edit (if desired). [Deleting an Order Edit](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Forders%2Fedits%2F%7Bid%7D%3ADELETE) does not affect the related Order. ##### State To check the state of an Order Edit, use the `result` field. ```mermaid flowchart TB np[NotProcessed] ap[Applied] pf[PreviewFailure] ps[PreviewSuccess] np --> ps & pf pf <--> ps ps --> ap ``` (a CSV formatted table follows. The first line are the column names.) State,Description [NotProcessed](https://docs.commercetools.com/api/projects/order-edits.md#orderedit-notprocessed),The changes have not been applied to the Order. This status shows on results returned from the [Query OrderEdits](https://docs.commercetools.com/urn?urn=ctp%3Aapi%3Aendpoint%3A%2F%7BprojectKey%7D%2Forders%2Fedits%3AGET) endpoint. [PreviewSuccess](https://docs.commercetools.com/api/projects/order-edits.md#orderedit-previewsuccess),A preview of the modified Order, including any available Messages, is available for evaluation. This status can show after OrderEdit creation and when an OrderEdit is fetched or updated via key or ID. [PreviewFailure](https://docs.commercetools.com/api/projects/order-edits.md#orderedit-previewfailure),A preview could not be generated due to one or more invalid changes specified in the `errors` field. This status can show after OrderEdit creation and when an OrderEdit is fetched or updated via key or ID. [Applied](https://docs.commercetools.com/api/projects/order-edits.md#orderedit-applied),The changes have been applied to the Order. This state contains information detailing the state before (`excerptBeforeEdit`) and after (`excerptAfterEdit`) the OrderEdit was applied. Once applied, any additional changes must be done in a new OrderEdit. ## Overview of update actions for Cart, Order, and Order Edit (a CSV formatted table follows. The first line are the column names.) Update action,Cart,Order,Order Edit Set Key,[✓](https://docs.commercetools.com/api/projects/carts.md#set-key),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-key) Set Order Number,-,[✓](https://docs.commercetools.com/api/projects/orders.md#set-order-number),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-order-number) Set Purchase Order Number,[✓](https://docs.commercetools.com/api/projects/carts.md#set-purchase-order-number),[✓](https://docs.commercetools.com/api/projects/orders.md#set-purchase-order-number),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-purchase-order-number) Set Customer ID,[✓](https://docs.commercetools.com/api/projects/carts.md#set-customer-id),[✓](https://docs.commercetools.com/api/projects/orders.md#set-customer-id),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-customer-id) Set Customer Email,[✓](https://docs.commercetools.com/api/projects/carts.md#set-customer-email),[✓](https://docs.commercetools.com/api/projects/orders.md#set-customer-email),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-customer-email) Set Customer Group,[✓](https://docs.commercetools.com/api/projects/carts.md#set-customer-group),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-customer-group) Set Anonymous ID,[✓](https://docs.commercetools.com/api/projects/carts.md#set-anonymous-id),-,- Set Business Unit ,[✓](https://docs.commercetools.com/api/projects/carts.md#set-business-unit),[✓](https://docs.commercetools.com/api/projects/orders.md#set-business-unit),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-business-unit) Add LineItem,[✓](https://docs.commercetools.com/api/projects/carts.md#add-lineitem),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#add-lineitem) Remove LineItem,[✓](https://docs.commercetools.com/api/projects/carts.md#remove-lineitem),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#remove-lineitem) Add CustomLineItem,[✓](https://docs.commercetools.com/api/projects/carts.md#add-customlineitem),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#add-customlineitem) Remove CustomLineItem,[✓](https://docs.commercetools.com/api/projects/carts.md#remove-customlineitem),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#remove-customlineitem) Add Shopping List,[✓](https://docs.commercetools.com/api/projects/carts.md#add-shopping-list),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#add-shopping-list) Set Cart Total Tax,[✓](https://docs.commercetools.com/api/projects/carts.md#set-cart-total-tax),-,- Set Order Total Tax,-,-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-order-total-tax) Change TaxMode,[✓](https://docs.commercetools.com/api/projects/carts.md#change-taxmode),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#change-taxmode) Change Price RoundingMode,[✓](https://docs.commercetools.com/api/projects/carts.md#change-price-roundingmode),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#change-price-roundingmode) Change Tax RoundingMode,[✓](https://docs.commercetools.com/api/projects/carts.md#change-tax-roundingmode),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#change-tax-roundingmode) Change Tax CalculationMode,[✓](https://docs.commercetools.com/api/projects/carts.md#change-taxcalculationmode),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#change-taxcalculationmode) Add DiscountCode,[✓](https://docs.commercetools.com/api/projects/carts.md#add-discountcode),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#add-discountcode) Remove DiscountCode,[✓](https://docs.commercetools.com/api/projects/carts.md#remove-discountcode),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#remove-discountcode) Set DirectDiscounts,[✓](https://docs.commercetools.com/api/projects/carts.md#set-directdiscounts),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-directdiscounts) Add Payment,[✓](https://docs.commercetools.com/api/projects/carts.md#add-payment),[✓](https://docs.commercetools.com/api/projects/orders.md#add-payment),[✓](https://docs.commercetools.com/api/projects/order-edits.md#add-payment) Remove Payment,[✓](https://docs.commercetools.com/api/projects/carts.md#remove-payment),[✓](https://docs.commercetools.com/api/projects/orders.md#remove-payment),[✓](https://docs.commercetools.com/api/projects/order-edits.md#remove-payment) Change PaymentState,-,[✓](https://docs.commercetools.com/api/projects/orders.md#change-paymentstate),[✓](https://docs.commercetools.com/api/projects/order-edits.md#change-paymentstate) Set Billing Address,[✓](https://docs.commercetools.com/api/projects/carts.md#set-billing-address),[✓](https://docs.commercetools.com/api/projects/orders.md#set-billing-address),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-billing-address) Set Shipping Address,[✓](https://docs.commercetools.com/api/projects/carts.md#set-shipping-address),[✓](https://docs.commercetools.com/api/projects/orders.md#set-shipping-address),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-shipping-address) Add ItemShippingAddress,[✓](https://docs.commercetools.com/api/projects/carts.md#add-itemshippingaddress),[✓](https://docs.commercetools.com/api/projects/orders.md#add-itemshippingaddress),[✓](https://docs.commercetools.com/api/projects/order-edits.md#add-itemshippingaddress) Remove ItemShippingAddress,[✓](https://docs.commercetools.com/api/projects/carts.md#remove-itemshippingaddress),[✓](https://docs.commercetools.com/api/projects/orders.md#remove-itemshippingaddress),[✓](https://docs.commercetools.com/api/projects/order-edits.md#remove-itemshippingaddress) Update ItemShippingAddress,[✓](https://docs.commercetools.com/api/projects/carts.md#update-itemshippingaddress),[✓](https://docs.commercetools.com/api/projects/orders.md#update-itemshippingaddress),[✓](https://docs.commercetools.com/api/projects/order-edits.md#update-itemshippingaddress) Add ShippingMethod,[✓](https://docs.commercetools.com/api/projects/carts.md#add-shippingmethod),-,- Add Custom ShippingMethod,[✓](https://docs.commercetools.com/api/projects/carts.md#add-custom-shippingmethod),-,- Remove Shipping Method,[✓](https://docs.commercetools.com/api/projects/carts.md#remove-shippingmethod),-,- Set ShippingMethod,[✓](https://docs.commercetools.com/api/projects/carts.md#set-shippingmethod),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-shippingmethod) Set ShippingAddress and ShippingMethod,-,-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-shippingaddress-and-shippingmethod) Set ShippingAddress and Custom ShippingMethod,-,-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-shippingaddress-and-custom-shippingmethod) Set Custom ShippingMethod,[✓](https://docs.commercetools.com/api/projects/carts.md#set-custom-shippingmethod),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-custom-shippingmethod) Set ShippingRateInput,[✓](https://docs.commercetools.com/api/projects/carts.md#set-shippingrateinput),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-shippingrateinput) Add Delivery,-,[✓](https://docs.commercetools.com/api/projects/orders.md#add-delivery),[✓](https://docs.commercetools.com/api/projects/order-edits.md#add-delivery) Remove Delivery,-,[✓](https://docs.commercetools.com/api/projects/orders.md#remove-delivery),[✓](https://docs.commercetools.com/api/projects/order-edits.md#remove-delivery) Change ShipmentState,-,[✓](https://docs.commercetools.com/api/projects/orders.md#change-shipmentstate),[✓](https://docs.commercetools.com/api/projects/order-edits.md#change-shipmentstate) Add ReturnInfo,-,[✓](https://docs.commercetools.com/api/projects/orders.md#add-returninfo),[✓](https://docs.commercetools.com/api/projects/order-edits.md#add-returninfo) Set ReturnInfo,-,[✓](https://docs.commercetools.com/api/projects/orders.md#set-returninfo),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-returninfo) Set ReturnShipmentState,-,[✓](https://docs.commercetools.com/api/projects/orders.md#set-returnshipmentstate),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-returnshipmentstate) Set ReturnPaymentState,-,[✓](https://docs.commercetools.com/api/projects/orders.md#set-returnpaymentstate),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-returnpaymentstate) Change OrderState,-,[✓](https://docs.commercetools.com/api/projects/orders.md#change-orderstate),[✓](https://docs.commercetools.com/api/projects/order-edits.md#change-orderstate) Transition State,-,[✓](https://docs.commercetools.com/api/projects/orders.md#transition-state),[✓](https://docs.commercetools.com/api/projects/order-edits.md#transition-state) Update SyncInfo,-,[✓](https://docs.commercetools.com/api/projects/orders.md#update-syncinfo),[✓](https://docs.commercetools.com/api/projects/order-edits.md#update-syncinfo) Set Locale,[✓](https://docs.commercetools.com/api/projects/carts.md#set-locale),[✓](https://docs.commercetools.com/api/projects/orders.md#set-locale),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-locale) Set Country,[✓](https://docs.commercetools.com/api/projects/carts.md#set-country),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-country) Set Store,-,[✓](https://docs.commercetools.com/api/projects/orders.md#set-store),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-store) Set Custom Type,[✓](https://docs.commercetools.com/api/projects/carts.md#set-custom-type),[✓](https://docs.commercetools.com/api/projects/orders.md#set-custom-type),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-custom-type) Set CustomField,[✓](https://docs.commercetools.com/api/projects/carts.md#set-customfield),[✓](https://docs.commercetools.com/api/projects/orders.md#set-customfield),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-customfield) Set DeleteDaysAfterLastModification,[✓](https://docs.commercetools.com/api/projects/carts.md#set-deletedaysafterlastmodification),-,- Freeze Cart,[✓](https://docs.commercetools.com/api/projects/carts.md#freeze-cart),-,- Unfreeze Cart,[✓](https://docs.commercetools.com/api/projects/carts.md#unfreeze-cart),-,- Lock Cart,[✓](https://docs.commercetools.com/api/projects/carts.md#lock-cart),-,- Unlock Cart,[✓](https://docs.commercetools.com/api/projects/carts.md#unlock-cart),-,- Recalculate,[✓](https://docs.commercetools.com/api/projects/carts.md#recalculate),-,- ### on LineItem (a CSV formatted table follows. The first line are the column names.) Update action,Cart,Order,Order Edit Change LineItem Quantity,[✓](https://docs.commercetools.com/api/projects/carts.md#change-lineitem-quantity),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#change-lineitem-quantity) Change LineItems Order,[✓](https://docs.commercetools.com/api/projects/carts.md#change-lineitems-order),-,- Set LineItem TaxRate,[✓](https://docs.commercetools.com/api/projects/carts.md#set-lineitem-taxrate),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-lineitem-taxrate) Set LineItem TaxAmount,[✓](https://docs.commercetools.com/api/projects/carts.md#set-lineitem-taxamount),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-lineitem-taxamount) Set LineItem Price,[✓](https://docs.commercetools.com/api/projects/carts.md#set-lineitem-price),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-lineitem-price) Set LineItem TotalPrice,[✓](https://docs.commercetools.com/api/projects/carts.md#set-lineitem-totalprice),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-lineitem-totalprice) Set LineItem DistributionChannel,[✓](https://docs.commercetools.com/api/projects/carts.md#set-lineitem-distributionchannel),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-lineitem-distributionchannel) Set LineItem ShippingDetails,[✓](https://docs.commercetools.com/api/projects/carts.md#set-lineitem-shippingdetails),[✓](https://docs.commercetools.com/api/projects/orders.md#set-lineitem-shippingdetails),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-lineitem-shippingdetails) Set LineItemRecurrenceInfo,[✓](https://docs.commercetools.com/api/projects/carts.md#set-lineitemrecurrenceinfo),-,- Apply DeltaToLineItemShippingDetailTargets,[✓](https://docs.commercetools.com/api/projects/carts.md#apply-deltatolineitemshippingdetailstargets),-,- Set LineItem Custom Type,[✓](https://docs.commercetools.com/api/projects/carts.md#set-lineitem-custom-type),[✓](https://docs.commercetools.com/api/projects/orders.md#set-lineitem-custom-type),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-lineitem-custom-type) Set LineItem CustomField,[✓](https://docs.commercetools.com/api/projects/carts.md#set-lineitem-customfield),[✓](https://docs.commercetools.com/api/projects/orders.md#set-lineitem-customfield),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-lineitem-customfield) Set LineItem InventoryMode,[✓](https://docs.commercetools.com/api/projects/carts.md#set-lineitem-inventorymode),-,- Set LineItem SupplyChannel,[✓](https://docs.commercetools.com/api/projects/carts.md#set-lineitem-supplychannel),-,- Transition LineItem State,-,[✓](https://docs.commercetools.com/api/projects/orders.md#transition-lineitem-state),[✓](https://docs.commercetools.com/api/projects/order-edits.md#transition-lineitem-state) Import LineItem State,-,[✓](https://docs.commercetools.com/api/projects/orders.md#import-lineitem-state),[✓](https://docs.commercetools.com/api/projects/order-edits.md#import-lineitem-state) ### on CustomLineItem (a CSV formatted table follows. The first line are the column names.) Update action,Cart,Order,Order Edit Change CustomLineItem Quantity,[✓](https://docs.commercetools.com/api/projects/carts.md#change-customlineitem-quantity),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#change-customlineitem-quantity) Set CustomLineItem TaxRate,[✓](https://docs.commercetools.com/api/projects/carts.md#set-customlineitem-taxrate),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-customlineitem-taxrate) Set CustomLineItem TaxAmount,[✓](https://docs.commercetools.com/api/projects/carts.md#set-customlineitem-taxamount),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-customlineitem-taxamount) Change CustomLineItem Money,[✓](https://docs.commercetools.com/api/projects/carts.md#change-customlineitem-money),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#change-customlineitem-money) Change CustomLineItem Price Mode,[✓](https://docs.commercetools.com/api/projects/carts.md#change-customlineitem-price-mode),-,- Set CustomLineItem ShippingDetails,[✓](https://docs.commercetools.com/api/projects/carts.md#set-customlineitem-shippingdetails),[✓](https://docs.commercetools.com/api/projects/orders.md#set-customlineitem-shippingdetails),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-customlineitem-shippingdetails) Set CustomLineItemRecurrenceInfo,[✓](https://docs.commercetools.com/api/projects/carts.md#set-customlineitemrecurrenceinfo),-,- Apply DeltaToCustomLineItemShippingDetailsTargets,[✓](https://docs.commercetools.com/api/projects/carts.md#apply-deltatocustomlineitemshippingdetailstargets),-,- Set CustomLineItem Custom Type,[✓](https://docs.commercetools.com/api/projects/carts.md#set-customlineitem-custom-type),[✓](https://docs.commercetools.com/api/projects/orders.md#set-customlineitem-custom-type),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-customlineitem-custom-type) Set CustomLineItem CustomField,[✓](https://docs.commercetools.com/api/projects/carts.md#set-customlineitem-customfield),[✓](https://docs.commercetools.com/api/projects/orders.md#set-customlineitem-customfield),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-customlineitem-customfield) Transition CustomLineItem State,-,[✓](https://docs.commercetools.com/api/projects/orders.md#transition-customlineitem-state),[✓](https://docs.commercetools.com/api/projects/order-edits.md#transition-customlineitem-state) Import CustomLineItem State,-,[✓](https://docs.commercetools.com/api/projects/orders.md#import-customlineitem-state),[✓](https://docs.commercetools.com/api/projects/order-edits.md#import-customlineitem-state) ### on Billing Address (a CSV formatted table follows. The first line are the column names.) Update action,Cart,Order,Order Edit Set Billing Address Custom Type,[✓](https://docs.commercetools.com/api/projects/carts.md#set-billing-address-custom-type),[✓](https://docs.commercetools.com/api/projects/orders.md#set-billing-address-custom-type),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-billing-address-custom-type) Set Billing Address CustomField,[✓](https://docs.commercetools.com/api/projects/carts.md#set-billing-address-customfield),[✓](https://docs.commercetools.com/api/projects/orders.md#set-billing-address-customfield),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-billing-address-customfield) ### on Shipping Address (a CSV formatted table follows. The first line are the column names.) Update action,Cart,Order,Order Edit Set Shipping Address Custom Type,[✓](https://docs.commercetools.com/api/projects/carts.md#set-shipping-address-custom-type),[✓](https://docs.commercetools.com/api/projects/orders.md#set-shipping-address-custom-type),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-shipping-address-custom-type) Set Shipping Address CustomField,[✓](https://docs.commercetools.com/api/projects/carts.md#set-shipping-address-customfield),[✓](https://docs.commercetools.com/api/projects/orders.md#set-shipping-address-customfield),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-shipping-address-customfield) ### on ItemShipping Address (a CSV formatted table follows. The first line are the column names.) Update action,Cart,Order,Order Edit Set ItemShipping Address Custom Type,[✓](https://docs.commercetools.com/api/projects/carts.md#set-itemshipping-address-custom-type),[✓](https://docs.commercetools.com/api/projects/orders.md#set-itemshipping-address-custom-type),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-itemshipping-address-custom-type) Set ItemShipping Address CustomField,[✓](https://docs.commercetools.com/api/projects/carts.md#set-itemshipping-address-customfield),[✓](https://docs.commercetools.com/api/projects/orders.md#set-itemshipping-address-customfield),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-itemshipping-address-customfield) ### on ShippingMethod (a CSV formatted table follows. The first line are the column names.) Update action,Cart,Order,Order Edit Set ShippingMethod TaxAmount,[✓](https://docs.commercetools.com/api/projects/carts.md#set-shippingmethod-taxamount),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-shippingmethod-taxamount) Set ShippingMethod TaxRate,[✓](https://docs.commercetools.com/api/projects/carts.md#set-shippingmethod-taxrate),-,[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-shippingmethod-taxrate) ### on Shipping (a CSV formatted table follows. The first line are the column names.) Update action,Cart,Order,Order Edit Set Shipping Custom Type,[✓](https://docs.commercetools.com/api/projects/carts.md#set-shipping-custom-type),[✓](https://docs.commercetools.com/api/projects/orders.md#set-shipping-custom-type),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-shipping-custom-type) Set Shipping CustomField,[✓](https://docs.commercetools.com/api/projects/carts.md#set-shipping-customfield),[✓](https://docs.commercetools.com/api/projects/orders.md#set-shipping-customfield),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-shipping-customfield) ### on Delivery (a CSV formatted table follows. The first line are the column names.) Update action,Cart,Order,Order Edit Set Delivery Address,-,[✓](https://docs.commercetools.com/api/projects/orders.md#set-delivery-address),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-delivery-address) Add Parcel to Delivery,-,[✓](https://docs.commercetools.com/api/projects/orders.md#add-parcel-to-delivery),[✓](https://docs.commercetools.com/api/projects/order-edits.md#add-parcel-to-delivery) Remove Parcel from Delivery,-,[✓](https://docs.commercetools.com/api/projects/orders.md#remove-parcel-from-delivery),[✓](https://docs.commercetools.com/api/projects/order-edits.md#remove-parcel-from-delivery) Set Delivery Items,-,[✓](https://docs.commercetools.com/api/projects/orders.md#set-delivery-items),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-delivery-items) Set Delivery Custom Type,-,[✓](https://docs.commercetools.com/api/projects/orders.md#set-delivery-custom-type),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-delivery-custom-type) Set Delivery CustomField,-,[✓](https://docs.commercetools.com/api/projects/orders.md#set-delivery-customfield),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-delivery-customfield) ### on Delivery Address (a CSV formatted table follows. The first line are the column names.) Update action,Cart,Order,Order Edit Set Delivery Address Custom Type,-,[✓](https://docs.commercetools.com/api/projects/orders.md#set-delivery-address-custom-type),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-delivery-address-custom-type) Set Delivery Address CustomField,-,[✓](https://docs.commercetools.com/api/projects/orders.md#set-delivery-address-customfield),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-delivery-address-customfield) ### on Parcel (a CSV formatted table follows. The first line are the column names.) Update action,Cart,Order,Order Edit Set Parcel Measurements,-,[✓](https://docs.commercetools.com/api/projects/orders.md#set-parcel-measurements),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-parcel-measurements) Set Parcel Tracking Data,-,[✓](https://docs.commercetools.com/api/projects/orders.md#set-parcel-tracking-data),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-parcel-tracking-data) Set Parcel Items,-,[✓](https://docs.commercetools.com/api/projects/orders.md#set-parcel-items),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-parcel-items) Set Parcel Custom Type,-,[✓](https://docs.commercetools.com/api/projects/orders.md#set-parcel-custom-type),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-parcel-custom-type) Set Parcel CustomField,-,[✓](https://docs.commercetools.com/api/projects/orders.md#set-parcel-customfield),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-parcel-customfield) ### on ReturnItem (a CSV formatted table follows. The first line are the column names.) Update action,Cart,Order,Order Edit Set ReturnItem Custom Type,-,[✓](https://docs.commercetools.com/api/projects/orders.md#set-returnitem-custom-type),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-returnitem-custom-type) Set ReturnItem CustomField,-,[✓](https://docs.commercetools.com/api/projects/orders.md#set-returnitem-customfield),[✓](https://docs.commercetools.com/api/projects/order-edits.md#set-returnitem-customfield) ## Further resources For best practices on optimizing the performance of large or complex Carts, see [Large Cart performance tips](https://docs.commercetools.com/api/large-cart-performance-tips.md). ## Related pages - [Section overview page](https://docs.commercetools.com/api.md) - [Next page: Carts](https://docs.commercetools.com/api/projects/carts.md)