This guide will help you set up the order management system for SolMart.
- A Supabase project with the following environment variables:
NEXT_PUBLIC_SUPABASE_URLNEXT_PUBLIC_SUPABASE_ANON_KEY
-
Create the orders table in Supabase:
- Go to your Supabase dashboard
- Navigate to the SQL Editor
- Run the SQL script from
supabase-setup.sql
-
Verify the table structure: The orders table should have the following columns:
id(UUID, Primary Key)user_wallet(TEXT, Required)user_email(TEXT, Optional)items(JSONB, Required)total_amount(DECIMAL, Required)status(TEXT, Required, Default: 'pending')transaction_signature(TEXT, Optional)tracking_number(TEXT, Optional)estimated_delivery(TEXT, Optional)shipping_address(JSONB, Optional)notes(TEXT, Optional)created_at(TIMESTAMP, Auto-generated)updated_at(TIMESTAMP, Auto-updated)
- When users complete a payment, orders are automatically stored in Supabase
- Order includes user wallet address, items, total amount, and transaction details
- Orders start with 'pending' status
- Users can view their order history at
/orders - Orders are filtered by the connected wallet address
- Search functionality to find specific orders
- Real-time order status updates
- Access admin panel at
/admin - View all orders with filtering and search
- Update order status (pending → processing → shipped → delivered)
- Add tracking numbers and estimated delivery dates
- View order statistics and analytics
- Pending: Order created, payment confirmed
- Processing: Order is being prepared
- Shipped: Order has been shipped with tracking
- Delivered: Order completed
- Cancelled: Order cancelled
- Add items to cart
- Connect wallet and checkout
- View order history at
/orders - Track order status and delivery
- Access
/adminwith connected wallet - View all orders and statistics
- Update order status as needed
- Add tracking information for shipped orders
- Monitor order flow and customer satisfaction
- Row Level Security (RLS) enabled on orders table
- Users can only view their own orders
- Admin policies can be customized based on your requirements
- Wallet-based authentication for order access
To restrict admin access to specific wallets, modify the admin policy in Supabase:
-- Example: Allow specific wallet addresses admin access
CREATE POLICY "Specific admins can manage all orders" ON orders
FOR ALL USING (
user_wallet IN ('admin_wallet_1', 'admin_wallet_2')
);You can extend the system to send email notifications when:
- Order is created
- Order status changes
- Order is shipped with tracking
The system supports shipping address storage. You can add a form to collect shipping addresses during checkout.
- Orders not appearing: Check if the wallet is connected and authenticated
- Admin access denied: Verify admin wallet policies in Supabase
- Order creation fails: Check Supabase connection and table permissions
- Status updates not working: Verify RLS policies allow admin operations
- Check browser console for errors
- Verify Supabase environment variables
- Test database connection in Supabase dashboard
- Check RLS policies and permissions
- Set up email notifications for order updates
- Add shipping address collection during checkout
- Implement order cancellation functionality
- Add order analytics and reporting
- Create seller-specific order views
- Add bulk order operations for admins