# Addon-Module Integration Strategy **Date**: December 26, 2025 **Status**: 🎯 Proposal --- ## Vision **Module Registry as the Single Source of Truth for all extensions** - both built-in modules and external addons. --- ## Current State Analysis ### What We Have #### 1. **Module System** (Just Built) - `ModuleRegistry.php` - Manages built-in modules - Enable/disable functionality - Module metadata (label, description, features, icon) - Categories (Marketing, Customers, Products) - Settings page UI with toggles #### 2. **Addon System** (Existing) - `AddonRegistry.php` - Manages external addons - SPA route injection - Hook system integration - Navigation tree injection - React component loading ### The Opportunity **These two systems should be unified!** An addon is just an external module. --- ## Proposed Integration ### Concept: Unified Extension Registry ``` ┌─────────────────────────────────────────────────┐ │ Module Registry (Single Source) │ ├─────────────────────────────────────────────────┤ │ │ │ Built-in Modules External Addons │ │ ├─ Newsletter ├─ Biteship Shipping │ │ ├─ Wishlist ├─ Subscriptions │ │ ├─ Affiliate ├─ Bookings │ │ ├─ Subscription └─ Custom Reports │ │ └─ Licensing │ │ │ │ All share same interface: │ │ • Enable/disable toggle │ │ • Settings page (optional) │ │ • Icon & metadata │ │ • Feature list │ │ │ └─────────────────────────────────────────────────┘ ``` --- ## Implementation Plan ### Phase 1: Extend Module Registry for Addons #### Backend: ModuleRegistry.php Enhancement ```php class ModuleRegistry { /** * Get all modules (built-in + addons) */ public static function get_all_modules() { $builtin = self::get_builtin_modules(); $addons = self::get_addon_modules(); return array_merge($builtin, $addons); } /** * Get addon modules from AddonRegistry */ private static function get_addon_modules() { $addons = apply_filters('woonoow/addon_registry', []); $modules = []; foreach ($addons as $addon_id => $addon) { $modules[$addon_id] = [ 'id' => $addon_id, 'label' => $addon['name'], 'description' => $addon['description'] ?? '', 'category' => $addon['category'] ?? 'addons', 'icon' => $addon['icon'] ?? 'puzzle', 'default_enabled' => false, 'features' => $addon['features'] ?? [], 'is_addon' => true, 'version' => $addon['version'] ?? '1.0.0', 'author' => $addon['author'] ?? '', 'settings_url' => $addon['settings_url'] ?? '', // NEW! ]; } return $modules; } } ``` #### Addon Registration Enhancement ```php // Addon developers register with enhanced metadata add_filter('woonoow/addon_registry', function($addons) { $addons['biteship-shipping'] = [ 'id' => 'biteship-shipping', 'name' => 'Biteship Shipping', 'description' => 'Indonesia shipping with Biteship API', 'version' => '1.0.0', 'author' => 'WooNooW Team', 'category' => 'shipping', // NEW! 'icon' => 'truck', // NEW! 'features' => [ // NEW! 'Real-time shipping rates', 'Multiple couriers', 'Tracking integration', ], 'settings_url' => '/settings/shipping/biteship', // NEW! 'spa_bundle' => plugin_dir_url(__FILE__) . 'dist/addon.js', ]; return $addons; }); ``` --- ### Phase 2: Module Settings Page with Gear Icon #### UI Enhancement: Modules.tsx ```tsx {modules.map((module) => (
{/* Icon */}
{getIcon(module.icon)}
{/* Content */}

{module.label}

{module.enabled && Active} {module.is_addon && Addon}

{module.description}

{/* Features */}
{/* Actions */}
{/* Settings Gear Icon - Only if module has settings */} {module.settings_url && module.enabled && ( )} {/* Enable/Disable Toggle */} toggleModule.mutate({ moduleId: module.id, enabled })} />
))} ``` --- ### Phase 3: Dynamic Categories #### Support for Addon Categories ```php // ModuleRegistry.php public static function get_categories() { return [ 'marketing' => __('Marketing & Sales', 'woonoow'), 'customers' => __('Customer Experience', 'woonoow'), 'products' => __('Products & Inventory', 'woonoow'), 'shipping' => __('Shipping & Fulfillment', 'woonoow'), // NEW! 'payments' => __('Payments & Checkout', 'woonoow'), // NEW! 'analytics' => __('Analytics & Reports', 'woonoow'), // NEW! 'addons' => __('Other Extensions', 'woonoow'), // Fallback ]; } ``` #### Frontend: Dynamic Category Rendering ```tsx // Modules.tsx const { data: modulesData } = useQuery({ queryKey: ['modules'], queryFn: async () => { const response = await api.get('/modules'); return response as ModulesData; }, }); // Get unique categories from modules const categories = Object.keys(modulesData?.grouped || {}); return ( {categories.map((category) => { const modules = modulesData.grouped[category] || []; if (modules.length === 0) return null; return ( {/* Module cards */} ); })} ); ``` --- ## Benefits ### 1. **Unified Management** - ✅ One place to see all extensions (built-in + addons) - ✅ Consistent enable/disable interface - ✅ Unified metadata (icon, description, features) ### 2. **Better UX** - ✅ Users don't need to distinguish between "modules" and "addons" - ✅ Settings gear icon for quick access to module configuration - ✅ Clear visual indication of what's enabled ### 3. **Developer Experience** - ✅ Addon developers use familiar pattern - ✅ Automatic integration with module system - ✅ No extra work to appear in Modules page ### 4. **Extensibility** - ✅ Dynamic categories support any addon type - ✅ Settings URL allows deep linking to config - ✅ Version and author info for better management --- ## Example: Biteship Addon Integration ### Addon Registration (PHP) ```php 'biteship-shipping', 'name' => 'Biteship Shipping', 'description' => 'Real-time shipping rates from Indonesian couriers', 'version' => '1.0.0', 'author' => 'WooNooW Team', 'category' => 'shipping', 'icon' => 'truck', 'features' => [ 'JNE, J&T, SiCepat, and more', 'Real-time rate calculation', 'Shipment tracking', 'Automatic label printing', ], 'settings_url' => '/settings/shipping/biteship', 'spa_bundle' => plugin_dir_url(__FILE__) . 'dist/addon.js', ]; return $addons; }); // Register settings route add_filter('woonoow/spa_routes', function($routes) { $routes[] = [ 'path' => '/settings/shipping/biteship', 'component_url' => plugin_dir_url(__FILE__) . 'dist/Settings.js', 'title' => 'Biteship Settings', ]; return $routes; }); ``` ### Result in Modules Page ``` ┌─────────────────────────────────────────────────┐ │ Shipping & Fulfillment │ ├─────────────────────────────────────────────────┤ │ │ │ 🚚 Biteship Shipping [⚙️] [Toggle] │ │ Real-time shipping rates from Indonesian... │ │ • JNE, J&T, SiCepat, and more │ │ • Real-time rate calculation │ │ • Shipment tracking │ │ • Automatic label printing │ │ │ │ Version: 1.0.0 | By: WooNooW Team | [Addon] │ │ │ └─────────────────────────────────────────────────┘ ``` Clicking ⚙️ navigates to `/settings/shipping/biteship` --- ## Migration Path ### Step 1: Enhance ModuleRegistry (Backward Compatible) - Add `get_addon_modules()` method - Merge built-in + addon modules - No breaking changes ### Step 2: Update Modules UI - Add gear icon for settings - Add "Addon" badge - Support dynamic categories ### Step 3: Document for Addon Developers - Update ADDON_DEVELOPMENT_GUIDE.md - Add examples with new metadata - Show settings page pattern ### Step 4: Update Existing Addons (Optional) - Addons work without changes - Enhanced metadata is optional - Settings URL is optional --- ## API Changes ### New Module Properties ```typescript interface Module { id: string; label: string; description: string; category: string; icon: string; default_enabled: boolean; features: string[]; enabled: boolean; // NEW for addons is_addon?: boolean; version?: string; author?: string; settings_url?: string; // Route to settings page } ``` ### New API Endpoint (Optional) ```php // GET /woonoow/v1/modules/:module_id/settings // Returns module-specific settings schema ``` --- ## Settings Page Pattern ### Option 1: Dedicated Route (Recommended) ```php // Addon registers its own settings route add_filter('woonoow/spa_routes', function($routes) { $routes[] = [ 'path' => '/settings/my-addon', 'component_url' => plugin_dir_url(__FILE__) . 'dist/Settings.js', ]; return $routes; }); ``` ### Option 2: Modal/Drawer (Alternative) ```tsx // Modules page opens modal with addon settings ``` --- ## Backward Compatibility ### Existing Addons Continue to Work - ✅ No breaking changes - ✅ Enhanced metadata is optional - ✅ Addons without metadata still function - ✅ Gradual migration path ### Existing Modules Unaffected - ✅ Built-in modules work as before - ✅ No changes to existing module logic - ✅ Only UI enhancement --- ## Summary ### What This Achieves 1. **Newsletter Footer Integration** ✅ - Newsletter form respects module status - Hidden from footer builder when disabled 2. **Addon-Module Unification** 🎯 - Addons appear in Module Registry - Same enable/disable interface - Settings gear icon for configuration 3. **Better Developer Experience** 🎯 - Consistent registration pattern - Automatic UI integration - Optional settings page routing 4. **Better User Experience** 🎯 - One place to manage all extensions - Clear visual hierarchy - Quick access to settings ### Next Steps 1. ✅ Newsletter footer integration (DONE) 2. 🎯 Enhance ModuleRegistry for addon support 3. 🎯 Add settings URL support to Modules UI 4. 🎯 Update documentation 5. 🎯 Create example addon with settings --- **This creates a truly unified extension system where built-in modules and external addons are first-class citizens with the same management interface.**