## 🐛 Critical Fixes ### Issue 1: Toggle Refuses to Disable **Problem:** Channels always return `enabled: true` even after toggling off **Root Cause:** Response didn't include actual saved state **Fix:** Added verification and return actual state in response **Changes:** ```php // Update option update_option($option_key, (bool) $enabled, false); // Verify the update $verified = get_option($option_key); // Return verified state return [ 'channelId' => $channel_id, 'enabled' => (bool) $verified, ]; ``` ### Issue 2: Wrong Event Channel Defaults **Problem:** - Email showing as enabled by default in frontend - Push showing as disabled in frontend - Mismatch between frontend and backend **Root Cause:** 1. Wrong path: `$settings['event_id']` instead of `$settings['event_id']['channels']` 2. Defaults set to `true` instead of `false` **Fix:** ```php // Before 'channels' => $settings['order_placed'] ?? ['email' => ['enabled' => true, ...]] // After 'channels' => $settings['order_placed']['channels'] ?? [ 'email' => ['enabled' => false, 'recipient' => 'admin'], 'push' => ['enabled' => false, 'recipient' => 'admin'] ] ``` ### What Was Fixed 1. ✅ Channel toggle now saves correctly 2. ✅ Response includes verified state 3. ✅ Event channels default to `false` (disabled) 4. ✅ Both email and push included in defaults 5. ✅ Correct path to saved settings 6. ✅ Consistent behavior across all events ### Testing - [ ] Toggle email off → stays off - [ ] Toggle push off → stays off - [ ] Reload page → state persists - [ ] Events page shows correct defaults (all disabled) - [ ] Enable per-event channel → saves correctly --- **Toggles should now work properly!** ✅
17 KiB
17 KiB