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
This commit is contained in:
@@ -66,20 +66,26 @@ class EmailManager {
|
||||
add_action('woocommerce_product_set_stock', [$this, 'check_stock_levels'], 10, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if WooNooW notification system is enabled
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function is_enabled() {
|
||||
// Check global notification system mode
|
||||
$system_mode = get_option('woonoow_notification_system_mode', 'woonoow');
|
||||
return $system_mode === 'woonoow';
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable WooCommerce default emails
|
||||
*
|
||||
* @param WC_Emails $email_class
|
||||
*/
|
||||
public function disable_wc_emails($email_class) {
|
||||
// Get WooNooW notification settings
|
||||
$settings = get_option('woonoow_notification_settings', []);
|
||||
|
||||
// Check if custom emails are enabled (default: yes)
|
||||
$use_custom_emails = $settings['use_custom_emails'] ?? true;
|
||||
|
||||
if (!$use_custom_emails) {
|
||||
return; // Keep WC emails if custom emails disabled
|
||||
// Only disable WC emails if WooNooW system is enabled
|
||||
if (!self::is_enabled()) {
|
||||
return; // Keep WC emails if WooNooW system disabled
|
||||
}
|
||||
|
||||
// Disable all WooCommerce transactional emails
|
||||
|
||||
Reference in New Issue
Block a user