- Add WP Media Library integration for product and variation images - Support images array (URLs) conversion to attachment IDs - Add images array to API responses (Admin & Customer SPA) - Implement drag-and-drop sortable images in Admin product form - Add image gallery thumbnails in Customer SPA product page - Initialize WooCommerce session for guest cart operations - Fix product variations and attributes display in Customer SPA - Add variation image field in Admin SPA Changes: - includes/Api/ProductsController.php: Handle images array, add to responses - includes/Frontend/ShopController.php: Add images array for customer SPA - includes/Frontend/CartController.php: Initialize WC session for guests - admin-spa/src/lib/wp-media.ts: Add openWPMediaGallery function - admin-spa/src/routes/Products/partials/tabs/GeneralTab.tsx: WP Media + sortable images - admin-spa/src/routes/Products/partials/tabs/VariationsTab.tsx: Add variation image field - customer-spa/src/pages/Product/index.tsx: Add gallery thumbnails display
6.5 KiB
Sprint 3-4: Product Catalog & Cart
Duration: Sprint 3-4 (2 weeks)
Status: 🚀 Ready to Start
Prerequisites: ✅ Sprint 1-2 Complete
Objectives
Build out the complete product catalog experience and shopping cart functionality.
Sprint 3: Product Catalog Enhancement
- Product Detail Page - Full product view with variations
- Product Filters - Category, price, attributes
- Product Search - Real-time search with debouncing
- Product Sorting - Price, popularity, rating, date
Sprint 4: Shopping Cart
- Cart Page - View and manage cart items
- Cart Sidebar - Quick cart preview
- Cart API Integration - Sync with WooCommerce cart
- Coupon Application - Apply and remove coupons
Sprint 3: Product Catalog Enhancement
1. Product Detail Page (/product/:id)
File: customer-spa/src/pages/Product/index.tsx
Features:
- Product images gallery with zoom
- Product title, price, description
- Variation selector (size, color, etc.)
- Quantity selector
- Add to cart button
- Related products
- Product reviews (if enabled)
API Endpoints:
GET /shop/products/:id- Get product detailsGET /shop/products/:id/related- Get related products (optional)
Components to Create:
ProductGallery.tsx- Image gallery with thumbnailsVariationSelector.tsx- Select product variationsQuantityInput.tsx- Quantity selectorProductMeta.tsx- SKU, categories, tagsRelatedProducts.tsx- Related products carousel
2. Product Filters
File: customer-spa/src/components/Shop/Filters.tsx
Features:
- Category filter (tree structure)
- Price range slider
- Attribute filters (color, size, brand, etc.)
- Stock status filter
- On sale filter
- Clear all filters button
State Management:
- Use URL query parameters for filters
- Persist filters in URL for sharing
Components:
CategoryFilter.tsx- Hierarchical category treePriceRangeFilter.tsx- Price sliderAttributeFilter.tsx- Checkbox list for attributesActiveFilters.tsx- Show active filters with remove buttons
3. Product Search Enhancement
Current: Basic search input
Enhancement: Real-time search with suggestions
Features:
- Search as you type
- Search suggestions dropdown
- Recent searches
- Popular searches
- Product thumbnails in results
- Keyboard navigation (arrow keys, enter, escape)
File: customer-spa/src/components/Shop/SearchBar.tsx
4. Product Sorting
Features:
- Sort by: Default, Popularity, Rating, Price (low to high), Price (high to low), Latest
- Dropdown selector
- Persist in URL
File: customer-spa/src/components/Shop/SortDropdown.tsx
Sprint 4: Shopping Cart
1. Cart Page (/cart)
File: customer-spa/src/pages/Cart/index.tsx
Features:
- Cart items list with thumbnails
- Quantity adjustment (+ / -)
- Remove item button
- Update cart button
- Cart totals (subtotal, tax, shipping, total)
- Coupon code input
- Proceed to checkout button
- Continue shopping link
- Empty cart state
Components:
CartItem.tsx- Single cart item rowCartTotals.tsx- Cart totals summaryCouponForm.tsx- Apply coupon codeEmptyCart.tsx- Empty cart message
2. Cart Sidebar/Drawer
File: customer-spa/src/components/Cart/CartDrawer.tsx
Features:
- Slide-in from right
- Mini cart items (max 5, then scroll)
- Cart totals
- View cart button
- Checkout button
- Close button
- Backdrop overlay
Trigger:
- Click cart icon in header
- Auto-open when item added (optional)
3. Cart API Integration
Endpoints:
GET /cart- Get current cartPOST /cart/add- Add item to cartPUT /cart/update- Update item quantityDELETE /cart/remove- Remove itemPOST /cart/apply-coupon- Apply couponDELETE /cart/remove-coupon- Remove coupon
State Management:
- Zustand store already created (
customer-spa/src/lib/cart/store.ts) - Sync with WooCommerce session
- Persist cart in localStorage
- Handle cart conflicts (server vs local)
4. Coupon System
Features:
- Apply coupon code
- Show discount amount
- Show coupon description
- Remove coupon button
- Error handling (invalid, expired, usage limit)
Backend:
- Already implemented in
CartController.php POST /cart/apply-couponDELETE /cart/remove-coupon
Technical Considerations
Performance
- Lazy load product images
- Implement infinite scroll for product grid (optional)
- Cache product data with TanStack Query
- Debounce search and filter inputs
UX Enhancements
- Loading skeletons for all states
- Optimistic updates for cart actions
- Toast notifications for user feedback
- Smooth transitions and animations
- Mobile-first responsive design
Error Handling
- Network errors
- Out of stock products
- Invalid variations
- Cart conflicts
- API timeouts
Accessibility
- Keyboard navigation
- Screen reader support
- Focus management
- ARIA labels
- Color contrast
Implementation Order
Week 1 (Sprint 3)
-
Day 1-2: Product Detail Page
- Basic layout and product info
- Image gallery
- Add to cart functionality
-
Day 3: Variation Selector
- Handle simple and variable products
- Update price based on variation
- Validation
-
Day 4-5: Filters & Search
- Category filter
- Price range filter
- Search enhancement
- Sort dropdown
Week 2 (Sprint 4)
-
Day 1-2: Cart Page
- Cart items list
- Quantity adjustment
- Cart totals
- Coupon application
-
Day 3: Cart Drawer
- Slide-in sidebar
- Mini cart items
- Quick actions
-
Day 4: Cart API Integration
- Sync with backend
- Handle conflicts
- Error handling
-
Day 5: Polish & Testing
- Responsive design
- Loading states
- Error states
- Cross-browser testing
Success Criteria
Sprint 3
- ✅ Product detail page displays all product info
- ✅ Variations can be selected and price updates
- ✅ Filters work and update product list
- ✅ Search returns relevant results
- ✅ Sorting works correctly
Sprint 4
- ✅ Cart page displays all cart items
- ✅ Quantity can be adjusted
- ✅ Items can be removed
- ✅ Coupons can be applied and removed
- ✅ Cart drawer opens and closes smoothly
- ✅ Cart syncs with WooCommerce backend
- ✅ Cart persists across page reloads
Next Steps
- Review this plan
- Confirm priorities
- Start with Product Detail Page
- Implement features incrementally
- Test each feature before moving to next
Ready to start Sprint 3? 🚀