Overview
Orders Admin API provides comprehensive order management tools for platform administrators. Includes order listing with filtering, status management, revenue analytics, store performance rankings, and bulk delete operations. All functions require admin authorization. Location:convex/admins/ordersAdmin.ts
Get All Orders
Fetches all orders with filtering and cursor-based pagination. Orders are returned newest first, enriched with customer name, store name, and item count. Supports filtering by status, store, customer, date range, and text search (searches customer name, store name, and order ID).Get Store Orders
Fetches orders for a specific store with pagination. Returns enriched orders with customer name, phone number, and item count, plus the store name and total order count.Get Order Status Counts
Returns live order counts grouped by status. Used for dashboard cards showing per-status totals. No arguments required.Get Order Statistics
Returns order statistics from the pre-computedadminOrderStats aggregate table. Supports daily or all-time views.
When no stats exist for the requested date, all values return as zero. The
averageOrderValue is calculated as totalRevenue / completedOrders.Get Order Details
Fetches full details for a single order, including enriched customer info, store info, order items, and status history timeline.Status history is sorted chronologically (oldest first). Order items already contain
productName and productImage from the original order.Update Order Status
Admin override to update an order’s status. Records the change in theorderStatusHistory table with the admin marked as a system user type.
Get Revenue Analytics
Returns revenue analytics grouped by time period. Only counts delivered (completed) orders.For
week grouping, the period key is the Sunday (start of week) date. For month grouping, the format is YYYY-MM. Results are sorted chronologically.Get Top Stores By Orders
Returns the top performing stores ranked by number of completed (delivered) orders, with revenue metrics.Bulk Delete Orders
Permanently deletes multiple orders and their associated status history records. Processes in batches of 50 using internal mutations.This is a Convex action that delegates to internal mutations in batches of 50. Each order’s status history entries from
orderStatusHistory are deleted before the order itself. Returns zero counts if an empty array is passed.