debug: Add comprehensive logging for toggle issue

Added debug logging to identify where enabled status is lost.

Backend Logging:
- Log what instance_settings["enabled"] value is read from DB
- Log the computed is_enabled boolean
- Log for both regular zones and Rest of World zone

Frontend Logging:
- Log all fetched zones data
- Log each method's enabled status
- Console output for easy debugging

This will show us:
1. What WooCommerce stores in DB
2. What backend reads from DB
3. What backend returns to frontend
4. What frontend receives
5. What frontend displays

Next: Check console + error logs to find the disconnect
This commit is contained in:
dwindown
2025-11-09 00:14:47 +07:00
parent b3c44a8e63
commit 2608f3ec38
2 changed files with 31 additions and 1 deletions

View File

@@ -38,7 +38,18 @@ export default function ShippingPage() {
// Fetch shipping zones from WooCommerce
const { data: zones = [], isLoading, refetch } = useQuery({
queryKey: ['shipping-zones'],
queryFn: () => api.get('/settings/shipping/zones'),
queryFn: async () => {
const data = await api.get('/settings/shipping/zones');
console.log('[Shipping] Fetched zones:', data);
// Log each zone's methods
data.forEach((zone: any) => {
console.log(`[Shipping] Zone "${zone.name}" (ID: ${zone.id}):`, zone.rates);
zone.rates?.forEach((rate: any) => {
console.log(` - ${rate.name}: enabled=${rate.enabled}`);
});
});
return data;
},
staleTime: 5 * 60 * 1000, // 5 minutes
});