setCartItemWithHttpInfo method

Future<Response> setCartItemWithHttpInfo(
  1. String id,
  2. CartItemSet cartItemSet
)

Set one item's quantity in a cart; zero removes it

Sets how many of one item a cart holds, and answers the whole updated cart. This is the ONE way a cart's contents change. The quantity is the RESULT, not a delta: sending 3 leaves 3 however many were there before, so a retry is safe and a double-submit cannot double an order. ZERO REMOVES the line — there is deliberately no separate delete, because removal is the same act at the boundary value and a second spelling would be a second set of edge cases. Name the item with EITHER product OR variant, never both. Prefer variant for anything sold in sizes, colours or tiers: the price and the stock belong to the variant, so a product-level line on a varianted product prices the wrong thing. Either may be given as an id or as the human key — a product's URL slug, a variant's SKU — which is what lets a storefront add to cart straight from a product page URL without a lookup first. The item's price and name are CACHED onto the line as it is added, so the cart keeps the price the shopper was shown even if the catalog moves underneath it. An item that resolves to nothing in the catalog is refused 400 and the cart is left exactly as it was; nothing is partially applied. A named handler, not a closure, so zipdoc can lift this prose into the registry.

Note: This method returns the HTTP Response.

Parameters:

  • String id (required): ID is the cart to amend, from the path.

  • CartItemSet cartItemSet (required):

Implementation

Future<Response> setCartItemWithHttpInfo(String id, CartItemSet cartItemSet,) async {
  // ignore: prefer_const_declarations
  final path = r'/v1/commerce/cart/{id}/item'
    .replaceAll('{id}', id);

  // ignore: prefer_final_locals
  Object? postBody = cartItemSet;

  final queryParams = <QueryParam>[];
  final headerParams = <String, String>{};
  final formParams = <String, String>{};

  const contentTypes = <String>['application/json'];


  return apiClient.invokeAPI(
    path,
    'POST',
    queryParams,
    postBody,
    headerParams,
    formParams,
    contentTypes.isEmpty ? null : contentTypes.first,
  );
}