Dwindi Ramadhana
b8f179a984
feat: password reset email event with WooNooW template
2026-01-01 20:54:27 +07:00
dwindown
af2a3d3dd5
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!
2025-11-18 18:25:27 +07:00
dwindown
7394d2f213
feat: Add comprehensive email flow diagnostics and logging
...
🔍 Email Flow Diagnostic Tool:
Created test-email-flow.php - comprehensive diagnostic dashboard:
- System status (notification mode, email channel, Action Scheduler)
- Event configuration checker
- Email queue status (wp_options)
- Action Scheduler queue status
- Recent email logs viewer
- Test actions (queue test email, process queue, test order email)
- Troubleshooting guide
📝 Enhanced Debug Logging:
Added detailed logging to EmailManager:
- Hook trigger logging
- Order validation logging
- Event enabled/disabled logging
- Email rendering status
- wp_mail() call result
- Full email flow traceability
🎯 Usage:
1. Visit: /wp-content/plugins/woonoow/test-email-flow.php
2. Check all system status indicators
3. Use test buttons to trigger emails
4. Monitor debug logs for detailed flow
📋 Logs to Watch:
[EmailManager] send_order_processing_email triggered
[EmailManager] order_processing email is disabled/enabled
[EmailManager] Sending order_processing email
[EmailManager] Email rendered successfully
[EmailManager] wp_mail called - Result: success/failed
[WooNooW MailQueue] Queued email ID
[WooNooW MailQueue] Processing email_id
[WooNooW MailQueue] Sent and deleted email ID
🚀 Troubleshooting Steps:
1. Check notification system mode (woonoow vs woocommerce)
2. Check email channel enabled
3. Check event-specific email enabled
4. Check Action Scheduler for failures
5. Check debug logs for flow
6. Test with diagnostic tool
2025-11-18 15:44:08 +07:00
dwindown
60658c6786
feat: Complete backend wiring for notification system
...
✅ Global System Toggle:
- Added GET/POST /notifications/system-mode endpoints
- Switch between WooNooW and WooCommerce notification systems
- Stored in: woonoow_notification_system_mode
- EmailManager::is_enabled() checks system mode
- NotificationManager checks mode before sending
✅ Template System Wired:
- Templates saved via API are used when sending
- EmailRenderer fetches templates from TemplateProvider
- Variables replaced automatically
- Markdown parsed (cards, buttons, images)
- Email customization applied (colors, logo, branding)
✅ Channel Toggle Wired:
- Frontend toggles saved to database
- NotificationManager::is_channel_enabled() checks before sending
- Email: woonoow_email_notifications_enabled
- Push: woonoow_push_notifications_enabled
✅ Event Toggle Wired:
- Per-event channel settings saved
- NotificationManager::is_event_channel_enabled() checks before sending
- Stored in: woonoow_notification_settings
✅ Email Sending Flow:
Event → EmailManager → Check System Mode → Check Channel Toggle
→ Check Event Toggle → EmailRenderer → Get Template → Replace Variables
→ Parse Markdown → Apply Branding → wp_mail() → Sent
✅ All Settings Applied:
- Template modifications saved and used
- Channel toggles respected
- Event toggles respected
- Global system mode respected
- Email customization applied
- Push settings applied
📋 Modified Files:
- NotificationsController.php: Added system-mode endpoints
- NotificationManager.php: Added system mode check, wired EmailRenderer
- EmailManager.php: Added is_enabled() check for system mode
🎯 Result: Complete end-to-end notification system fully functional
2025-11-15 21:59:46 +07:00
dwindown
30384464a1
feat: Custom email system foundation
...
## ✅ Step 1-3: Email System Core
### EmailManager.php
- ✅ Disables WooCommerce emails (prevents duplicates)
- ✅ Hooks into all WC order status changes
- ✅ Hooks into customer, product events
- ✅ Checks if events are enabled before sending
- ✅ Sends via wp_mail() (SMTP plugin compatible)
### EmailRenderer.php
- ✅ Renders emails with design templates
- ✅ Variable replacement system
- ✅ Gets recipient email (staff/customer)
- ✅ Loads order/product/customer variables
- ✅ Filter hook: `woonoow_email_template`
- ✅ Supports HTML template designs
### Email Design Templates (3)
**templates/emails/modern.html**
- ✅ Clean, minimalist, Apple-inspired
- ✅ Dark mode support
- ✅ Mobile responsive
- ✅ 2024 design trends
**templates/emails/classic.html**
- ✅ Professional, traditional
- ✅ Gradient header
- ✅ Table styling
- ✅ Business-appropriate
**templates/emails/minimal.html**
- ✅ Ultra-clean, monospace font
- ✅ Black & white aesthetic
- ✅ Text-focused
- ✅ Dark mode invert
### Architecture
```
Design Template (HTML) → Content Template (Text) → Final Email
modern.html → order_processing → Beautiful HTML
```
---
**Next:** Rich text editor + Content templates 🎨
2025-11-12 18:48:55 +07:00