fix: Enable email notifications by default with default templates
🐛 CRITICAL FIX - Root Cause Found: Problem 1: Events Not Enabled by Default - is_event_enabled() returned false if not configured - Required explicit admin configuration - Plugin didn't work out-of-the-box Solution: - Enable email notifications by default if not configured - Allow plugin to work with default templates - Users can still disable via admin if needed Problem 2: Default Templates Not Loading - EmailRenderer called get_template() with only 2 args - Missing $recipient_type parameter - Default template lookup failed Solution: - Pass recipient_type to get_template() - Proper default template lookup - Added debug logging for template resolution 📝 Changes: 1. EmailManager::is_event_enabled() - Returns true by default for email channel - Logs when using default (not configured) - Respects explicit disable if configured 2. EmailRenderer::get_template_settings() - Pass recipient_type to TemplateProvider - Log template found/not found - Proper default template resolution 🎯 Result: - Plugin works out-of-the-box - Default templates used if not customized - Email notifications sent without configuration - Users can still customize in admin ✅ Expected Behavior: 1. Install plugin 2. Create order 3. Email sent automatically (default template) 4. Customize templates in admin (optional) This fixes the issue where check-settings.php showed: - Email: ✗ NOT CONFIGURED - Templates: 0 Now it will use defaults and send emails!
This commit is contained in:
@@ -361,11 +361,20 @@ class EmailManager {
|
||||
private function is_event_enabled($event_id, $channel_id, $recipient_type) {
|
||||
$settings = get_option('woonoow_notification_settings', []);
|
||||
|
||||
// Check if event exists and channel is enabled
|
||||
// Check if event exists and channel is configured
|
||||
if (isset($settings['events'][$event_id]['channels'][$channel_id])) {
|
||||
return $settings['events'][$event_id]['channels'][$channel_id]['enabled'] ?? false;
|
||||
}
|
||||
|
||||
// Default: enable email notifications if not explicitly configured
|
||||
// This allows the plugin to work out-of-the-box with default templates
|
||||
if ($channel_id === 'email') {
|
||||
if (defined('WP_DEBUG') && WP_DEBUG) {
|
||||
error_log('[EmailManager] Event not configured, using default: enabled');
|
||||
}
|
||||
return true; // Enable by default
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user