Adding to Cart
Your shopping cart holds books you're ready to purchase. Managing your cart is simple and flexible.
Adding Books to Cart
From Book Details
The most common way to add books:
- Open book details for any available book
- Tap the Add to Cart button (varies by availability)
- Book is added to cart
- Overlay automatically closes
- Confirmation: "Added to cart"
Button Variations:
- "Buy at [Store Name]" - In-stock at home store
- "Order Through [Store Name]" - Special order through home store
- "Order Now" - BookWish Direct (no home store set)
What Gets Added
When you add a book to cart:
Stored Information:
- Book ID - References the book
- Quantity - Starts at 1
- Price at add - Current price when added
- Store ID - Your home store (if applicable)
- Item ID - Unique cart item identifier
Cart State Updates
After adding:
- Cart provider refreshes automatically
- Navigation bar cart icon updates with item count
- Cart page shows new item
- Totals recalculate
Viewing Your Cart
Cart Page
Access your cart:
- Tap Cart icon in navigation bar
- Navigate to cart from menu
- Go directly from checkout prompt
Cart Page Layout:
- App bar with "Cart" title
- Scrollable list of items
- Total summary at bottom
- Checkout button
Empty Cart
If your cart is empty:
- "Cart is empty" message displays
- Gray cart icon
- No checkout button
- Prompt to browse books
Cart Items
Each item in your cart shows:
Book Information:
- Title - Book title in book title typography
- Price - Price when added (in dollars and cents)
- Thumbnail - Book cover or placeholder (if available in full implementation)
Actions:
- Remove button - Trash icon to delete item
Item Layout
Cart items appear as list tiles:
[Book Title]
$XX.XX
[Trash Icon]
Simple, clear presentation focuses on essentials.
Managing Cart Items
Removing Items
To remove a book from your cart:
- Find the item in cart list
- Tap the trash icon button
- Item immediately removed
- Cart refreshes
- Totals update
What Happens:
- Item deleted from cart
removeItem()method called- Cart provider refreshes
- UI updates automatically
No Confirmation:
- Items remove immediately
- No undo option currently
- Can re-add from book details if needed
Quantity Management
Current Implementation:
- Quantity set to 1 when adding
- Can be updated via
updateQuantity()method - Updates persist in cart state
The UI for changing quantities in the cart page may be enhanced in future versions. Currently, quantities are managed through the provider's updateQuantity() method.
Cart Totals
Total Calculation
The cart summary shows:
- Label: "Total:"
- Amount: Calculated total in dollars
- Typography: Heading style, bold for amount
Total Includes:
- Subtotal (sum of all item prices)
- Tax (calculated at checkout)
- Shipping (if applicable)
Displayed Format:
- Currency symbol ($)
- Dollars and cents (2 decimal places)
- Example: "$45.98"
Cart Totals Model
The CartTotals object includes:
subtotalCents- Items subtotaltaxCents- Calculated taxshippingCents- Shipping costtotalCents- Grand total
All amounts stored as cents (integers) for precision, displayed as dollars.
Cart State Management
Cart Provider
The cart uses Riverpod state management:
Provider: cartNotifierProvider
State Type: AsyncValue<CartState>
CartState includes:
cart- Cart object with itemstotals- CartTotals objectisCheckingOut- Checkout status flag
Available Methods
Adding Items:
addToCart(String bookId, {int quantity = 1, String? storeId})
Updating Quantity:
updateQuantity(String itemId, int quantity)
Removing Items:
removeItem(String itemId)
Clearing Cart:
clear()
Refreshing:
refresh()
State Updates
Cart automatically refreshes after:
- Adding items
- Updating quantities
- Removing items
- Completing checkout
Cart Behavior
Persistence
Your cart:
- Persists across app sessions
- Stored on server per user
- Syncs across devices
- Retrieved on app launch
Cart Limits
No Hard Limits:
- Add as many items as needed
- No maximum quantity per item
- No maximum cart value
Practical Considerations:
- Performance may degrade with many items
- Checkout processes each item
- Inventory checked at checkout time
Checkout
Proceeding to Checkout
When ready to purchase:
- Review cart items and total
- Tap Checkout button
- Navigate to checkout page
- Complete checkout process
Requirements to Checkout:
- At least one item in cart
- Valid payment method (configured in checkout)
- Shipping address (for ship orders)
Button State:
- Enabled when cart has items
- Shows "Checkout" text
- Primary button style
See Checkout Process for complete details.
Cart During Checkout
While checking out:
- Cart state includes
isCheckingOut: true - Prevents modifications during processing
- Cart cleared on successful checkout
- Restored on checkout failure
Loading and Error States
Loading State
While cart loads:
- Spinner shown in center
- Circular progress indicator
- Appears on page load
- Brief for most users
Error State
If cart fails to load:
- Error message displayed
- "Error: [error message]" text
- Body typography style
- Centered on page
Common Errors:
- Network connectivity issues
- Server errors
- Authentication problems
Cart Analytics
Cart actions may be tracked:
- Items added
- Items removed
- Checkout initiated
- Abandoned carts
Used to improve the shopping experience.
Tips for Cart Management
- Review before checkout - Double-check items and quantities
- Remove unused items - Keep cart clean for faster checkout
- Note prices - Prices locked when added; won't change in cart
- Check availability - Inventory verified at checkout
- Save to wishlist - Use wishlist for "maybe later" items
Common Questions
Q: Does my cart expire? A: No, cart items persist indefinitely until you remove them or complete checkout.
Q: Can I save my cart? A: Your cart is automatically saved and syncs across your devices.
Q: What if a book becomes unavailable? A: You'll be notified at checkout if any items are no longer available.
Q: Can I apply discount codes? A: Discount features may be available during checkout. Check the checkout page for promotional options.
Q: Do prices change after adding to cart?
A: No, the price is locked when you add the item (priceAtAddCents).
Related Topics
- Checkout Process - Complete your purchase
- Book Availability - Understanding inventory
- Your Home Store - How your home store affects cart items