$event_data) { echo " - $event_id:\n"; if (isset($event_data['channels']['email'])) { $email_config = $event_data['channels']['email']; $enabled = $email_config['enabled'] ?? false; $status = $enabled ? '✓ ENABLED' : '✗ DISABLED'; echo " Email: $status\n"; if (isset($email_config['recipients'])) { echo " Recipients: " . implode(', ', array_keys($email_config['recipients'])) . "\n"; } } else { echo " Email: ✗ NOT CONFIGURED\n"; } } } else { echo " ⚠ No events configured\n"; } } // 4. Email Templates echo "\n4. Email Templates:\n"; $templates = get_option('woonoow_email_templates', []); if (empty($templates)) { echo " ✗ No email templates found!\n"; } else { echo " ✓ " . count($templates) . " template(s) found\n"; foreach ($templates as $template_id => $template_data) { echo " - $template_id: " . ($template_data['subject'] ?? 'no subject') . "\n"; } } // 5. WooCommerce Hooks echo "\n5. WooCommerce Hook Status:\n"; global $wp_filter; $hooks_to_check = [ 'woocommerce_order_status_pending_to_processing', 'woocommerce_order_status_pending_to_completed', 'woocommerce_order_status_processing_to_completed', 'woocommerce_order_status_completed', ]; foreach ($hooks_to_check as $hook) { if (isset($wp_filter[$hook])) { $callbacks = $wp_filter[$hook]->callbacks; $count = 0; foreach ($callbacks as $priority => $funcs) { $count += count($funcs); } echo " ✓ $hook: $count callback(s)\n"; } else { echo " ✗ $hook: NOT REGISTERED\n"; } } // 6. Mail Queue Hook echo "\n6. Mail Queue Hook:\n"; if (isset($wp_filter['woonoow/mail/send'])) { echo " ✓ woonoow/mail/send: REGISTERED\n"; } else { echo " ✗ woonoow/mail/send: NOT REGISTERED\n"; echo " This means MailQueue::init() was not called!\n"; } // 7. Action Scheduler echo "\n7. Action Scheduler:\n"; if (function_exists('as_enqueue_async_action')) { echo " ✓ Available\n"; global $wpdb; $stats = [ 'pending' => $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->prefix}actionscheduler_actions WHERE hook = 'woonoow/mail/send' AND status = 'pending'"), 'complete' => $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->prefix}actionscheduler_actions WHERE hook = 'woonoow/mail/send' AND status = 'complete'"), 'failed' => $wpdb->get_var("SELECT COUNT(*) FROM {$wpdb->prefix}actionscheduler_actions WHERE hook = 'woonoow/mail/send' AND status = 'failed'"), ]; echo " Pending: {$stats['pending']}\n"; echo " Complete: {$stats['complete']}\n"; echo " Failed: {$stats['failed']}\n"; } else { echo " ✗ Not available (using wp-cron)\n"; } // 8. Queued Emails echo "\n8. Queued Emails (wp_options):\n"; global $wpdb; $queued = $wpdb->get_results( "SELECT option_name, LENGTH(option_value) as size FROM {$wpdb->options} WHERE option_name LIKE 'woonoow_mail_%' ORDER BY option_id DESC LIMIT 10" ); if (empty($queued)) { echo " ⚠ No emails in queue\n"; } else { echo " " . count($queued) . " email(s) in queue:\n"; foreach ($queued as $row) { echo " - {$row->option_name} ({$row->size} bytes)\n"; } } echo "\n=== Summary ===\n"; echo "System Mode: $system_mode\n"; echo "Email Channel: " . ($email_enabled ? 'enabled' : 'disabled') . "\n"; echo "Events Configured: " . (isset($settings['events']) ? count($settings['events']) : 0) . "\n"; echo "Templates: " . count($templates) . "\n"; echo "Queued Emails: " . count($queued) . "\n"; echo "\n=== Recommendations ===\n"; if ($system_mode !== 'woonoow') { echo "⚠ Set notification system mode to 'woonoow'\n"; } if (!$email_enabled) { echo "⚠ Enable email channel\n"; } if (empty($settings['events'])) { echo "⚠ Configure events in notification settings\n"; } if (!isset($wp_filter['woonoow/mail/send'])) { echo "⚠ MailQueue hook not registered - check Bootstrap::init()\n"; } echo "\nDone!\n";