get_cart
Retrieve shopping cart details using a public key identifier to facilitate anonymous order processing and address linking.
Instructions
Retrieve a shopping cart by its Public Key ID. Uses W3SHIP_PUBLIC_KEY if no id is provided.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | Public key ID (hex). Optional if W3SHIP_PUBLIC_KEY is set. |
Implementation Reference
- src/index.ts:428-438 (handler)The get_cart tool handler in src/index.ts. It receives the cartId, calls valkeyService.getCart, and returns the cart data.
case 'get_cart': { const id = (args?.id as string) || CONFIGURED_KEY; if (!id) { return { content: [{ type: 'text', text: 'Error: No cart ID. Set W3SHIP_PUBLIC_KEY or provide an id.' }], isError: true }; } const cart = await valkeyService.getCart(id); if (!cart) { return { content: [{ type: 'text', text: `Error: Cart not found for ID ${id}` }], isError: true }; } return { content: [{ type: 'text', text: JSON.stringify(cart, null, 2) }] }; } - src/cart/service.ts:57-61 (handler)The actual implementation of getCart in valkeyService which interacts with the Valkey/Redis instance to retrieve the shopping cart.
async getCart(cartId: string): Promise<ShoppingCart | null> { const data = await this.getClient().get(`cart:${cartId}`); if (!data) return null; return JSON.parse(data); }