Overview
The Orders API provides comprehensive order management functionality including order creation, status updates, and retrieval for both customers and store owners. It supports real-time order tracking, automated notifications, and complete order lifecycle management. Location:convex/customers/orders.ts
Order Lifecycle
1
Pending
Order created, awaiting store confirmation
2
Confirmed
Store has confirmed the order and will start preparing
3
Preparing
Store is actively preparing the order
4
Ready
Order is ready for pickup or delivery
5
Out for Delivery
Order is on the way to customer (delivery only)
6
Delivered
Order has been completed successfully
Create Order
Creates a new order directly with specified items (alternative to cart-based ordering).Customer ID placing the order
Store ID receiving the order
Array of items with productId and quantity
Complete delivery address information
Delivery method selection
Delivery fee amount
Payment method used
Optional order notes
Estimated delivery time in minutes
Update Order Status
Update order status with optional notes (available to both store owners and customers).Order ID to update
New order status:
pending, confirmed, preparing, ready, out_for_delivery, delivered, cancelledOptional status update notes
Get Order Details
Retrieve detailed information about a specific order.Order ID to retrieve
Get Customer Orders
Retrieve all orders for a specific customer.Customer ID
Maximum number of orders to return
Get Store Orders
Retrieve orders for a specific store with optional status filtering.Store ID
Filter by order status
Maximum number of orders to return
Order Management Components
Complete order management interface:Order Status Flow
Pending
Initial Status: Order placed, awaiting store confirmation
Actions: Store can confirm or cancel
Actions: Store can confirm or cancel
Confirmed
Store Action: Store has accepted the order
Next: Store will start preparing
Next: Store will start preparing
Preparing
Active Status: Order is being prepared
ETA: Estimated completion time provided
ETA: Estimated completion time provided
Ready
Completion: Order ready for pickup/delivery
Actions: Dispatch for delivery or notify for pickup
Actions: Dispatch for delivery or notify for pickup
Out for Delivery
Transit: Order is on the way to customer
Tracking: Real-time delivery updates
Tracking: Real-time delivery updates
Delivered
Final Status: Order completed successfully
Actions: Review and rating available
Actions: Review and rating available
Error Handling
Order not found
Order not found
Status Code:
404Invalid status transition
Invalid status transition
Status Code:
400Insufficient permissions
Insufficient permissions
Status Code:
403Order creation failed
Order creation failed
Status Code:
400Order status updates automatically trigger notifications to relevant parties and update real-time dashboards for both customers and store owners.
