fix(customers): Add tabs to detail page and fix orders loading

Fixed 2 critical issues:

1.  Orders Not Loading:
Backend (OrdersController.php):
- Added customer_id parameter support
- Lines 300-304: Filter orders by customer
- Uses WooCommerce customer_id arg

Frontend (Detail.tsx):
- Already passing customer_id correctly
- Orders will now load properly

2.  Added Tabs for Better Organization:
Implemented 3-tab layout:

**Overview Tab:**
- Stats cards: Total Orders, Total Spent, Registered
- Contact information (email, phone)
- Clean, focused view

**Orders Tab:**
- Full order history (not just 10)
- Order count display
- Better empty state
- All orders clickable to detail

**Address Tab:**
- Billing address (full details)
- Shipping address (full details)
- Company names if available
- Phone in billing section
- Empty states for missing addresses

Benefits:
 Clean, organized, contextual data per tab
 No information overload
 Easy navigation between sections
 Better mobile experience
 Consistent with modern admin UX

Technical:
- Uses shadcn/ui Tabs component
- Responsive grid layouts
- Proper empty states
- Type-safe with TypeScript

Result: Customer detail page is now properly organized with working order history!
This commit is contained in:
dwindown
2025-11-21 00:37:11 +07:00
parent dbf9f42310
commit 46e7e6f7c9
2 changed files with 192 additions and 122 deletions

View File

@@ -296,6 +296,12 @@ class OrdersController {
if ( $search && preg_match( '/^#?(\\d+)$/', $search, $m ) ) {
$args['include'] = [ absint( $m[1] ) ];
}
// Optional customer filter
$customer_id = $req->get_param( 'customer_id' );
if ( $customer_id ) {
$args['customer_id'] = absint( $customer_id );
}
$result = wc_get_orders( $args );