From 9dffd38f50dc506f028055cd11f2707ba8e01b78 Mon Sep 17 00:00:00 2001 From: "Ronald A. Richardson" Date: Tue, 11 Aug 2026 21:48:24 +0800 Subject: [PATCH] fix(storefront): complete the cart line-item chain MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Update item in Cart and Remove item from cart addressed /carts/{id}/{line_item_id}. Single braces are not Postman variables, so both requested literal placeholders and answered "Invalid cart item provided to cart!". Nothing captured a line item id anywhere either — and it is the cart ITEM id (cart_item_*), not the product id, so {{product_id}} would not have worked. Add Item to Cart now captures {{line_item_id}} from items[0].id of the cart it returns, and both requests use {{cart_id}}/{{line_item_id}}. Update item in Cart also had no body, so the PUT updated nothing. It now sends {"quantity": 2}, which is what CartController::update reads. Its description read "You can update all properties of the Zone." — copy-pasted from the Zones collection into published Storefront documentation. Replaced with what the endpoint does. Co-Authored-By: Claude Opus 5 --- .../Cart/Add Item to Cart.request.yaml | 11 ++++++++++ .../Cart/Remove item from cart.request.yaml | 5 +---- .../Cart/Update item in Cart.request.yaml | 21 ++++++++++++------- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/postman/collections/Fleetbase Storefront API/Cart/Add Item to Cart.request.yaml b/postman/collections/Fleetbase Storefront API/Cart/Add Item to Cart.request.yaml index 0f56d26..cf296eb 100644 --- a/postman/collections/Fleetbase Storefront API/Cart/Add Item to Cart.request.yaml +++ b/postman/collections/Fleetbase Storefront API/Cart/Add Item to Cart.request.yaml @@ -14,4 +14,15 @@ body: "quantity": 1, "variants": [] } +scripts: + - type: afterResponse + code: |- + // Update item in Cart and Remove item from cart address {{line_item_id}} — + // the cart ITEM id (cart_item_*), not the product id. Nothing set it. + var json_response = pm.response.json(); + + if (Array.isArray(json_response.items) && json_response.items.length) { + pm.environment.set("line_item_id", json_response.items[0].id); + } + language: text/javascript order: 1000 diff --git a/postman/collections/Fleetbase Storefront API/Cart/Remove item from cart.request.yaml b/postman/collections/Fleetbase Storefront API/Cart/Remove item from cart.request.yaml index cb799b0..9cd4647 100644 --- a/postman/collections/Fleetbase Storefront API/Cart/Remove item from cart.request.yaml +++ b/postman/collections/Fleetbase Storefront API/Cart/Remove item from cart.request.yaml @@ -1,9 +1,6 @@ $kind: http-request description: |- Removes a line item or product from a cart. The response returns the updated cart after the item is removed. -url: "{{base_url}}/{{api_prefix}}/{{namespace}}/carts/{id}/{line_item_id}" +url: "{{base_url}}/{{api_prefix}}/{{namespace}}/carts/{{cart_id}}/{{line_item_id}}" method: DELETE -pathVariables: - id: "" - line_item_id: "" order: 4000 diff --git a/postman/collections/Fleetbase Storefront API/Cart/Update item in Cart.request.yaml b/postman/collections/Fleetbase Storefront API/Cart/Update item in Cart.request.yaml index 1718829..2e50339 100644 --- a/postman/collections/Fleetbase Storefront API/Cart/Update item in Cart.request.yaml +++ b/postman/collections/Fleetbase Storefront API/Cart/Update item in Cart.request.yaml @@ -1,10 +1,17 @@ $kind: http-request -description: |+ - You can update all properties of the Zone. - -url: "{{base_url}}/{{api_prefix}}/{{namespace}}/carts/{id}/{line_item_id}" +description: |- + Updates a line item already in the cart. Send any of `quantity`, `variants`, + `addons` or `scheduled_at`; omitted fields are left unchanged. The response + returns the updated cart. +url: "{{base_url}}/{{api_prefix}}/{{namespace}}/carts/{{cart_id}}/{{line_item_id}}" method: PUT -pathVariables: - id: "" - line_item_id: "" +headers: + - key: Content-Type + value: application/json +body: + type: json + content: |- + { + "quantity": 2 + } order: 3000