Introduce shopping carts and cart items. You’ll create carts, add and update items, and return computed totals. This module establishes the data flow that powers checkout in the final module.
Overview
Syllabus
- Unit 1: Managing Shopping Carts
- Observe how carts are created and fetched with totals
- Implement POST /api/carts to create a cart
- Implement GET /api/carts/:id to return items and totals
- Validate cart id and map errors correctly in the loader
- Unit 2: Adding Cart Line Items
- Observe how POST /api/carts/:id/items adds or increments line items
- Validate POST /api/carts/:id/items request bodies
- Implement transactional add-or-increment for cart items
- Enforce inventory when adding items and map HTTP status codes
- Unit 3: Managing Cart Line Items
- Observe how cart item updates and deletions are scoped to a cart
- Implement update and delete queries scoped to a cart
- Validate and enforce rules for updating cart item quantity
- Implement PATCH and DELETE branches with correct status codes