1573bff7b37a33a9ce50aa4c3f9e948f9e299885
8 Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
1573bff7b3 |
feat: Card-based email system implementation
## ✅ Core Card System Complete! ### base.html Template - ✅ Single, theme-agnostic template - ✅ Card system CSS (default, highlight, info, warning, success, bg) - ✅ Customizable header (logo/text) - ✅ Customizable footer + social icons - ✅ Customizable body background - ✅ Mobile responsive - ✅ Email client compatible (Outlook, Gmail, etc.) ### EmailRenderer.php - Card Parser - ✅ `parse_cards()` - Parses [card]...[/card] syntax - ✅ `parse_card_attributes()` - Extracts type and bg attributes - ✅ `render_card()` - Renders card HTML - ✅ `render_card_spacing()` - 24px spacing between cards - ✅ `render_html()` - Email customization support - ✅ `get_social_icon_url()` - Social media icons ### Card Types Supported ``` [card] → Default white card [card type="highlight"] → Purple gradient card [card type="info"] → Blue info card [card type="warning"] → Yellow warning card [card type="success"] → Green success card [card bg="https://..."] → Background image card ``` ### Email Customization - ✅ Header: Logo or text - ✅ Body background color - ✅ Footer text - ✅ Social media links (Facebook, Instagram, Twitter, LinkedIn) - ✅ Stored in `woonoow_notification_settings[email_appearance]` ### Default Templates Updated - ✅ order_placed_email - Multi-card layout - ✅ order_processing_email - Success card + summary - ✅ Other templates ready to update --- **Architecture:** ``` Content with [card] tags ↓ parse_cards() ↓ render_card() × N ↓ base.html template ↓ Beautiful HTML email! 🎨 ``` **Next:** Settings UI + Live Preview 🚀 |
||
|
|
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 🎨 |
||
|
|
c8adb9e924 |
feat: Integrate WooCommerce email templates
## ✅ Issue #4: WooCommerce Template Integration **TemplateProvider.php:** - ✅ Added `get_wc_email_template()` method - ✅ Loads actual WooCommerce email subjects - ✅ Falls back to custom defaults if WC not available - ✅ Maps WooNooW events to WC email classes: - order_placed → WC_Email_New_Order - order_processing → WC_Email_Customer_Processing_Order - order_completed → WC_Email_Customer_Completed_Order - order_cancelled → WC_Email_Cancelled_Order - order_refunded → WC_Email_Customer_Refunded_Order - new_customer → WC_Email_Customer_New_Account - customer_note → WC_Email_Customer_Note ### How It Works 1. On template load, checks if WooCommerce is active 2. Loads WC email objects via `WC()->mailer()->get_emails()` 3. Extracts subject, heading, enabled status 4. Uses WC subject as default, falls back to custom if not available 5. Body remains custom (WC templates are HTML, we use plain text) ### Benefits - ✅ Consistent with WooCommerce email settings - ✅ Respects store owner customizations - ✅ Automatic updates when WC emails change - ✅ Graceful fallback if WC not available --- **Result:** Templates now load from WooCommerce! 🎉 |
||
|
|
fbb0e87f6e |
feat: Add NotificationManager with dual-level toggle logic
## ✅ Notification Logic Implementation ### NotificationManager Class **Location:** `includes/Core/Notifications/NotificationManager.php` **Key Features:** 1. ✅ Dual-level validation (global + per-event) 2. ✅ Channel enabled checking 3. ✅ Event-channel enabled checking 4. ✅ Combined validation logic 5. ✅ Recipient management 6. ✅ Extensible for addons **Methods:** - `is_channel_enabled($channel_id)` - Global state - `is_event_channel_enabled($event_id, $channel_id)` - Event state - `should_send_notification($event_id, $channel_id)` - Combined validation - `get_recipient($event_id, $channel_id)` - Get recipient type - `send($event_id, $channel_id, $data)` - Send notification ### Logic Flow ``` ┌─────────────────────────────────┐ │ Global Channel Toggle │ │ (Channels Page) │ │ ✓ Affects ALL events │ └────────────┬────────────────────┘ │ ↓ ┌─────────────────────────────────┐ │ Per-Event Channel Toggle │ │ (Events Page) │ │ ✓ Affects specific event │ └────────────┬────────────────────┘ │ ↓ ┌─────────────────────────────────┐ │ Both Enabled? │ │ ✓ Yes → Send notification │ │ ✗ No → Skip │ └─────────────────────────────────┘ ``` ### Documentation **Added:** `NOTIFICATION_LOGIC.md` **Contents:** - Toggle hierarchy explanation - Decision logic with examples - Implementation details - Usage examples - Storage structure - Testing checklist - Future enhancements ### Integration Points **For Addon Developers:** ```php // Check before sending if (NotificationManager::should_send_notification($event_id, $channel_id)) { // Your addon logic here } // Hook into send add_filter('woonoow_send_notification', function($sent, $event_id, $channel_id, $recipient, $data) { if ($channel_id === 'my_channel') { // Handle your channel return my_send_function($data); } return $sent; }, 10, 5); ``` ### Testing **Manual Tests:** 1. ✅ Disable email globally → No emails 2. ✅ Enable email globally, disable per-event → Selective emails 3. ✅ Enable both → Emails sent 4. ✅ Same for push notifications 5. ✅ UI state persistence 6. ✅ Visual feedback (colors, toasts) --- **Notification system is production-ready with proper validation!** 🎯 |
||
|
|
26eb7cb898 |
feat: Implement push notification settings backend and UI
## ✅ Push Notification Settings - Fully Functional ### Backend (PHP) **PushNotificationHandler Updates:** - Added `SETTINGS_KEY` constant - `ensure_default_settings()` - Initialize defaults - `get_default_settings()` - Return default config - `get_settings()` - Fetch current settings - `update_settings()` - Save settings **Default Settings:** ```php [ 'use_logo' => true, 'use_product_images' => true, 'use_gravatar' => false, 'click_action' => '/wp-admin/admin.php?page=woonoow#/orders', 'require_interaction' => false, 'silent' => false, ] ``` **NotificationsController:** - `GET /notifications/push/settings` - Fetch settings - `POST /notifications/push/settings` - Update settings - Permission-protected endpoints ### Frontend (React) **ChannelConfig Component:** - Fetches push settings on open - Real-time state management - Connected switches and inputs - Save mutation with loading state - Toast notifications for success/error - Disabled state during save **Settings Available:** 1. **Branding** - Use Store Logo - Use Product Images - Use Customer Gravatar 2. **Behavior** - Click Action URL (input) - Require Interaction - Silent Notifications ### Features ✅ **Backend Storage** - Settings saved in wp_options ✅ **REST API** - GET and POST endpoints ✅ **Frontend UI** - Full CRUD interface ✅ **State Management** - React Query integration ✅ **Loading States** - Skeleton and button states ✅ **Error Handling** - Toast notifications ✅ **Default Values** - Sensible defaults --- **Next: Email channel toggle** 📧 |
||
|
|
97e76a837b |
feat: Add template editor and push notifications infrastructure
## ✅ Template Editor + Push Notifications ### Backend (PHP) **1. TemplateProvider** (`includes/Core/Notifications/TemplateProvider.php`) - Manages notification templates in wp_options - Default templates for all events x channels - Variable system (order, product, customer, store) - Template CRUD operations - Variable replacement engine **2. PushNotificationHandler** (`includes/Core/Notifications/PushNotificationHandler.php`) - VAPID keys generation and storage - Push subscription management - Queue system for push notifications - User-specific subscriptions - Service worker integration ready **3. NotificationsController** - Extended with: - GET /notifications/templates - List all templates - GET /notifications/templates/:eventId/:channelId - Get template - POST /notifications/templates - Save template - DELETE /notifications/templates/:eventId/:channelId - Reset to default - GET /notifications/push/vapid-key - Get VAPID public key - POST /notifications/push/subscribe - Subscribe to push - POST /notifications/push/unsubscribe - Unsubscribe **4. Push channel added to built-in channels** ### Frontend (React) **1. TemplateEditor Component** (`TemplateEditor.tsx`) - Modal dialog for editing templates - Subject + Body text editors - Variable insertion with dropdown - Click-to-insert variables - Live preview - Save and reset to default - Per event + channel customization **2. Templates Page** - Completely rewritten: - Lists all events x channels - Shows "Custom" badge for customized templates - Edit button opens template editor - Fetches templates from API - Variable reference guide - Organized by channel ### Key Features ✅ **Simple Text Editor** (not HTML builder) - Subject line - Body text with variables - Variable picker - Preview mode ✅ **Variable System** - Order variables: {order_number}, {order_total}, etc. - Customer variables: {customer_name}, {customer_email}, etc. - Product variables: {product_name}, {stock_quantity}, etc. - Store variables: {store_name}, {store_url}, etc. - Click to insert at cursor position ✅ **Push Notifications Ready** - VAPID key generation - Subscription management - Queue system - PWA integration ready - Built-in channel (alongside email) ✅ **Template Management** - Default templates for all events - Per-event, per-channel customization - Reset to default functionality - Custom badge indicator ### Default Templates Included **Email:** - Order Placed, Processing, Completed, Cancelled, Refunded - Low Stock, Out of Stock - New Customer, Customer Note **Push:** - Order Placed, Processing, Completed - Low Stock Alert ### Next Steps 1. ✅ Service worker for push notifications 2. ✅ Push subscription UI in Channels page 3. ✅ Test push notifications 4. ✅ Addon integration examples --- **Ready for testing!** 🚀 |
||
|
|
ffdc7aae5f |
feat: Implement notification system with 3 subpages (Events, Channels, Templates)
## ✅ Correct Implementation Following NOTIFICATION_STRATEGY.md ### Frontend (React) - 3 Subpages **1. Main Notifications Page** (`Notifications.tsx`) - Tab navigation for 3 sections - Events | Channels | Templates **2. Events Subpage** (`Notifications/Events.tsx`) - Configure which channels per event - Grouped by category (Orders, Products, Customers) - Toggle channels (Email, WhatsApp, Telegram, etc.) - Show recipient (Admin/Customer/Both) - Switch UI for enable/disable per channel **3. Channels Subpage** (`Notifications/Channels.tsx`) - List available channels - Built-in channels (Email) - Addon channels (WhatsApp, Telegram, SMS, Push) - Channel status (Active/Inactive) - Configure button for each channel - Addon discovery cards **4. Templates Subpage** (`Notifications/Templates.tsx`) - Email templates (link to WooCommerce) - Addon channel templates - Template variables reference - Preview and edit buttons - Variable documentation ({order_number}, {customer_name}, etc.) ### Backend (PHP) - Bridge to WooCommerce **NotificationsController** (`includes/Api/NotificationsController.php`) - Bridges to WooCommerce email system - Does NOT reinvent notification system - Provides addon integration hooks **REST API Endpoints:** ``` GET /notifications/channels - List channels (email + addons) GET /notifications/events - List events (maps to WC emails) POST /notifications/events/update - Update event channel settings ``` **Key Features:** ✅ Leverages WooCommerce emails (not reinventing) ✅ Stores settings in wp_options ✅ Provides hooks for addons: - `woonoow_notification_channels` filter - `woonoow_notification_events` filter - `woonoow_notification_event_updated` action ### Addon Integration **Example: WhatsApp Addon** ```php // Register channel add_filter("woonoow_notification_channels", function($channels) { $channels[] = [ "id" => "whatsapp", "label" => "WhatsApp", "icon" => "message-circle", "enabled" => true, "addon" => "woonoow-whatsapp", ]; return $channels; }); // React to event updates add_action("woonoow_notification_event_updated", function($event_id, $channel_id, $enabled, $recipient) { if ($channel_id === "whatsapp" && $enabled) { // Setup WhatsApp notification for this event } }, 10, 4); // Hook into WooCommerce email triggers add_action("woocommerce_order_status_processing", function($order_id) { // Send WhatsApp notification }, 10, 1); ``` ### Architecture **NOT a new notification system** ✅ - Uses WooCommerce email infrastructure - Maps events to WC email IDs - Addons hook into WC triggers **IS an extensible framework** ✅ - Unified UI for all channels - Per-event channel configuration - Template management - Addon discovery ### Files Created - `Notifications.tsx` - Main page with tabs - `Notifications/Events.tsx` - Events configuration - `Notifications/Channels.tsx` - Channel management - `Notifications/Templates.tsx` - Template editor - `NotificationsController.php` - REST API bridge ### Files Modified - `Routes.php` - Register NotificationsController --- **Ready for addon development!** 🚀 Next: Build Telegram addon as proof of concept |
||
|
|
01fc3eb36d |
feat: Implement notification system with extensible channel architecture
## ✅ Notification System Implementation Following NOTIFICATION_STRATEGY.md, built on top of WooCommerce email infrastructure. ### Backend (PHP) **1. NotificationManager** (`includes/Core/Notifications/NotificationManager.php`) - Central manager for notification system - Registers email channel (built-in) - Registers default notification events (orders, products, customers) - Provides hooks for addon channels - Maps to WooCommerce email IDs **2. NotificationSettingsProvider** (`includes/Core/Notifications/NotificationSettingsProvider.php`) - Manages settings in wp_options - Per-event channel configuration - Per-channel recipient settings (admin/customer/both) - Default settings with email enabled **3. NotificationsController** (`includes/Api/NotificationsController.php`) - REST API endpoints: - GET /notifications/channels - List available channels - GET /notifications/events - List notification events (grouped by category) - GET /notifications/settings - Get all settings - POST /notifications/settings - Update settings ### Frontend (React) **Updated Notifications.tsx:** - Shows available notification channels (email + addons) - Channel cards with built-in/addon badges - Event configuration by category (orders, products, customers) - Toggle channels per event with button UI - Link to WooCommerce advanced email settings - Responsive and modern UI ### Key Features ✅ **Built on WooCommerce Emails** - Email channel uses existing WC email system - No reinventing the wheel - Maps events to WC email IDs ✅ **Extensible Architecture** - Addons can register channels via hooks - `woonoow_notification_channels` filter - `woonoow_notification_send_{channel}` action - Per-event channel selection ✅ **User-Friendly UI** - Clear channel status (Active/Inactive) - Per-event channel toggles - Category grouping (orders, products, customers) - Addon discovery hints ✅ **Settings Storage** - Stored in wp_options (woonoow_notification_settings) - Per-event configuration - Per-channel settings - Default: email enabled for all events ### Addon Integration Example ```php // Addon registers WhatsApp channel add_action("woonoow_register_notification_channels", function() { NotificationManager::register_channel("whatsapp", [ "label" => "WhatsApp", "icon" => "message-circle", "addon" => "woonoow-whatsapp", ]); }); // Addon handles sending add_action("woonoow_notification_send_whatsapp", function($event_id, $data) { // Send WhatsApp message }, 10, 2); ``` ### Files Created - NotificationManager.php - NotificationSettingsProvider.php - NotificationsController.php ### Files Modified - Routes.php - Register NotificationsController - Bootstrap.php - Initialize NotificationManager - Notifications.tsx - New UI with channels and events --- **Ready for addon development!** 🚀 Next: Build Telegram addon as proof of concept |