get-user-cart
Method: GET
Path: /carts/users/{user_id}
Tags: Carts
Summary
Retrieve cart using user id
Description
Retrieve cart detail using user id
Storefront SDK Usage
SDK Method: sdk.cart.getUserCart()
Example:
typescript
const { data, error } = await sdk.cart.getUserCart({
user_id: "01H9USER12345ABCDE"
});
if (error) {
console.error("Failed to get user cart:", error.message);
} else {
console.log("User cart ID:", data.cart.id);
console.log("Cart value:", data.cart.subtotal_amount);
}TypeScript Definition
typescript
"get-user-cart": {
parameters: {
query?: never;
header?: never;
path: {
/** @description User ID */
user_id: string;
};
cookie?: never;
};
requestBody?: never;
responses: {
/** @description OK */
200: {
headers: {
[name: string]: unknown;
};
content: {
"application/json": {
/** @example cart details */
readonly message: string;
readonly success: boolean;
content: {
cart: components["schemas"]["Cart"];
};
};
};
};
401: components["responses"]["Unauthorized"];
404: components["responses"]["NotFound"];
};
};Component References
| Reference | Resolves To |
|---|---|
components["schemas"]["Cart"] | Cart |
components["responses"]["Unauthorized"] | Unauthorized |
components["responses"]["NotFound"] | NotFound |
Parameters
- user_id (path): User ID
Responses
200
OK
401
Not authorized for given operation on the Resource
404
Requested resource not found
OpenAPI Definition
json
{
"tags": [
"Carts"
],
"operationId": "get-user-cart",
"summary": "Retrieve cart using user id",
"description": "Retrieve cart detail using user id",
"externalDocs": {
"url": "https://llm-docs.commercengine.io/storefront/operations/get-user-cart",
"description": "API reference for the get-user-cart operation"
},
"parameters": [
{
"name": "user_id",
"in": "path",
"description": "User ID",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"type": "object",
"required": [
"message",
"success",
"content"
],
"properties": {
"message": {
"type": "string",
"examples": [
"cart details"
],
"readOnly": true
},
"success": {
"type": "boolean",
"readOnly": true
},
"content": {
"properties": {
"cart": {
"$ref": "#/components/schemas/Cart"
}
},
"required": [
"cart"
],
"type": "object"
}
}
}
}
}
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"404": {
"$ref": "#/components/responses/NotFound"
}
},
"security": [
{
"Authorization": []
}
],
"x-speakeasy-group": "carts",
"x-speakeasy-ignore": false,
"x-speakeasy-name-override": "getUserCart"
}Auto-generated from OpenAPI spec and TypeScript definitions