commercetools icon

commercetools

Interact with the commercetools API. Operations are auto-generated from the official Postman collection.

Actions671

Associate Cart → Update Cart in BusinessUnit by ID as Associate

AI-generated

Summary

Update a specific cart by its ID within a business unit context as an associate, applying one or more specified update actions to modify the cart.

Inputs

  • Associate Cart Key (required) — The key of the associate cart within the business unit.
  • Cart ID (required) — The unique identifier of the cart to update.
  • Associate ID (required) — The ID of the associate performing the update.
  • Version (required) — The current version of the cart for optimistic concurrency control.
  • Actions (JSON) — A raw JSON array of update actions to apply on the cart. If provided and not empty, this overrides the UI-configured actions.
  • Actions (UI) — One or more update actions configured via the user interface, representing modifications to the cart such as adding line items, setting shipping address, or applying discount codes.

Output shape

a single JSON object representing the updated cart resource as returned by the commercetools API.

The operation expects the cart version for concurrency control; providing out-of-date version will cause an error. Update actions can be specified either as raw JSON or through the UI fields — if JSON actions are provided and non-empty, they take precedence over UI actions.

Examples

Example 1: Add a discount code to a cart

Specify the Cart ID, Associate Cart Key, Associate ID, current Version, and configure an 'AddDiscountCode' action in the Actions (UI) with the appropriate code.

Example 2: Change the quantity of a line item in the cart

Provide the Cart ID, Associate Cart Key, Associate ID, current Version, and within Actions JSON input, include a 'changeLineItemQuantity' action with target line item ID and desired quantity.

Links

Discussion