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:
@@ -81,13 +81,20 @@ class EmailRenderer {
|
||||
* @return array|null
|
||||
*/
|
||||
private function get_template_settings($event_id, $recipient_type) {
|
||||
// Get saved template
|
||||
$template = TemplateProvider::get_template($event_id, 'email');
|
||||
// Get saved template (with recipient_type for proper default template lookup)
|
||||
$template = TemplateProvider::get_template($event_id, 'email', $recipient_type);
|
||||
|
||||
if (!$template) {
|
||||
if (defined('WP_DEBUG') && WP_DEBUG) {
|
||||
error_log('[EmailRenderer] No template found for event: ' . $event_id . ', recipient: ' . $recipient_type);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (defined('WP_DEBUG') && WP_DEBUG) {
|
||||
error_log('[EmailRenderer] Template found - Subject: ' . ($template['subject'] ?? 'no subject'));
|
||||
}
|
||||
|
||||
// Get design template preference
|
||||
$settings = get_option('woonoow_notification_settings', []);
|
||||
$design = $settings['email_design_template'] ?? 'modern';
|
||||
|
||||
Reference in New Issue
Block a user