Orders¶
Source: pharmanet/lib/features/orders/ + public/
Pages¶
| Page | File | Description |
|---|---|---|
CustomerOrderListPage |
features/orders/presentation/pages/customer_order_list_page.dart |
Customer order history |
OrderDetailsPage |
features/orders/presentation/pages/order_details_page.dart |
Full order detail |
TrackOrderPage |
features/orders/presentation/pages/track_order_page.dart |
Real-time order tracking |
PaymentSuccessPage |
features/orders/presentation/pages/payment_success_page.dart |
Post-payment confirmation |
OrdersPage |
features/public/presentation/pages/orders_page.dart |
Alternative order list |
API¶
Source: pharmanet/lib/core/api/order_api.dart
| Method | Description |
|---|---|
createOrder(items, shippingAddress, paymentMethod, notes) |
Place order (also triggers notifications) |
fetchOrders() |
Get current user's orders |
fetchUserOrders() |
Orders with items and status |
getOrderById(orderId) |
Full order details |
updatePaymentStatus(orderId, status) |
Update after Chapa callback |
cancelOrder(orderId, reason) |
Cancel with reason |
fetchOrderStatusHistory(orderId) |
Status change timeline |
Order States¶
Each status transition is logged in order_status_history with:
- Old status, new status
- Updated by (user/admin/system)
- Optional notes
- Timestamp
Providers¶
| Provider | Type | Description |
|---|---|---|
ordersProvider |
StateNotifierProvider<AsyncValue<List<Order>>> |
Order list |
orderStreamProvider |
StreamProvider<List<Map<String, dynamic>>> |
Real-time order updates |
orderDetailsProvider |
FutureProvider.family<String> |
Single order detail |
Real-Time Updates¶
Orders use Supabase Realtime subscriptions:
final orderStreamProvider = StreamProvider<List<Map<String, dynamic>>>((ref) {
final api = ref.read(orderApiProvider);
return api.supabase
.from('orders')
.stream(primaryKey: ['id'])
.eq('user_id', userId);
});
This means the order list and tracking page update automatically when the seller or admin changes the status.
Related¶
- Cart & Checkout — Order creation flow
- Payments — Payment processing
- Notifications — Order status notifications
- DB: Orders — Orders table schema