# WooNooW Feature Roadmap - 2025

**Last Updated**: December 26, 2025  
**Status**: Planning Phase

This document outlines the comprehensive feature roadmap for WooNooW, building upon existing infrastructure.

---

## 🎯 Strategic Overview

### Core Philosophy
1. **Modular Architecture** - Features can be enabled/disabled independently
2. **Reuse Infrastructure** - Leverage existing notification, validation, and API systems
3. **SPA-First** - Modern React UI for admin and customer experiences
4. **Extensible** - Filter hooks for customization and third-party integration

### Existing Foundation (Already Built)
- ✅ Notification System (email, WhatsApp, Telegram, push)
- ✅ Email Builder (visual blocks, markdown, preview)
- ✅ Validation Framework (email/phone with external API support)
- ✅ Newsletter Subscribers Management
- ✅ Coupon System
- ✅ Customer Wishlist (basic)
- ✅ Product Reviews & Ratings
- ✅ Admin SPA with modern UI
- ✅ Customer SPA with theme system
- ✅ REST API infrastructure
- ✅ Addon bridge pattern

---

## 📦 Module 1: Centralized Module Management

### Overview
Central control panel for enabling/disabling features to improve performance and reduce clutter.

### Status: **Planning** 🔵

### Implementation

#### Backend: Module Registry
**File**: `includes/Core/ModuleRegistry.php`

```php
<?php
namespace WooNooW\Core;

class ModuleRegistry {
    
    public static function get_all_modules() {
        $modules = [
            'newsletter' => [
                'id' => 'newsletter',
                'label' => 'Newsletter & Campaigns',
                'description' => 'Email newsletter subscription and campaign management',
                'category' => 'marketing',
                'default_enabled' => true,
            ],
            'wishlist' => [
                'id' => 'wishlist',
                'label' => 'Customer Wishlist',
                'description' => 'Allow customers to save products for later',
                'category' => 'customers',
                'default_enabled' => true,
            ],
            'affiliate' => [
                'id' => 'affiliate',
                'label' => 'Affiliate Program',
                'description' => 'Referral tracking and commission management',
                'category' => 'marketing',
                'default_enabled' => false,
            ],
        ];
        
        return apply_filters('woonoow/modules/registry', $modules);
    }
    
    public static function is_enabled($module_id) {
        $enabled = get_option('woonoow_enabled_modules', []);
        return in_array($module_id, $enabled);
    }
}
```

#### Frontend: Settings UI
**File**: `admin-spa/src/routes/Settings/Modules.tsx`

- Grouped by category (Marketing, Customers, Products)
- Toggle switches for each module
- Configure button (when enabled)
- Dependency badges

#### Navigation Integration
Only show module routes if enabled in navigation tree.

### Priority: **High** 🔴
### Effort: 1 week

---

## 📧 Module 2: Newsletter Campaigns

### Overview
Email broadcasting system for newsletter subscribers with design templates and campaign management.

### Status: **Planned** 🟢 (Architecture in NEWSLETTER_CAMPAIGN_PLAN.md)

### What's Already Built
- ✅ Subscriber management
- ✅ Email validation
- ✅ Email design templates (notification system)
- ✅ Email builder
- ✅ Email branding settings

### What's Needed

#### 1. Database Tables
```sql
wp_woonoow_campaigns (id, title, subject, content, template_id, status, scheduled_at, sent_at, total_recipients, sent_count, failed_count)
wp_woonoow_campaign_logs (id, campaign_id, subscriber_email, status, error_message, sent_at)
```

#### 2. Backend Components
- `CampaignsController.php` - CRUD API
- `CampaignSender.php` - Batch processor
- WP-Cron integration (hourly check)
- Error logging and retry

#### 3. Frontend Components
- Campaign list page
- Campaign editor (rich text for content)
- Template selector (reuse notification templates)
- Preview modal (merge template + content)
- Stats page

#### 4. Workflow
1. Create campaign (title, subject, select template, write content)
2. Preview (see merged email)
3. Send test email
4. Schedule or send immediately
5. System processes in batches (50 emails per batch, 5s delay)
6. Track results (sent, failed, errors)

### Priority: **High** 🔴
### Effort: 2-3 weeks

---

## 💝 Module 3: Wishlist Notifications

### Overview
Notify customers about wishlist events (price drops, back in stock, reminders).

### Status: **Planning** 🔵

### What's Already Built
- ✅ Wishlist functionality
- ✅ Notification system
- ✅ Email builder
- ✅ Product price/stock tracking

### What's Needed

#### 1. Notification Events
Add to `EventRegistry.php`:
- `wishlist_price_drop` - Price dropped by X%
- `wishlist_back_in_stock` - Out-of-stock item available
- `wishlist_low_stock` - Item running low
- `wishlist_reminder` - Remind after X days

#### 2. Tracking System
**File**: `includes/Core/WishlistNotificationTracker.php`

```php
class WishlistNotificationTracker {
    
    // WP-Cron daily job
    public function track_price_changes() {
        // Compare current price with last tracked
        // If dropped by threshold, trigger notification
    }
    
    // WP-Cron hourly job
    public function track_stock_status() {
        // Check if out-of-stock items are back
        // Trigger notification
    }
    
    // WP-Cron daily job
    public function send_reminders() {
        // Find wishlists not viewed in X days
        // Send reminder notification
    }
}
```

#### 3. Settings
- Enable/disable each notification type
- Price drop threshold (10%, 20%, 50%)
- Reminder frequency (7, 14, 30 days)
- Low stock threshold (5, 10 items)

#### 4. Email Templates
Create using existing email builder:
- Price drop (show old vs new price)
- Back in stock (with "Buy Now" button)
- Low stock alert (urgency)
- Wishlist reminder (list all items with images)

### Priority: **Medium** 🟡
### Effort: 1-2 weeks

---

## 🤝 Module 4: Affiliate Program

### Overview
Referral tracking and commission management system.

### Status: **Planning** 🔵

### What's Already Built
- ✅ Customer management
- ✅ Order tracking
- ✅ Notification system
- ✅ Admin SPA infrastructure

### What's Needed

#### 1. Database Tables
```sql
wp_woonoow_affiliates (id, user_id, referral_code, commission_rate, status, total_referrals, total_earnings, paid_earnings)
wp_woonoow_referrals (id, affiliate_id, order_id, customer_id, commission_amount, status, created_at, approved_at, paid_at)
wp_woonoow_affiliate_payouts (id, affiliate_id, amount, method, status, notes, created_at, completed_at)
```

#### 2. Tracking System
```php
class AffiliateTracker {
    
    // Set cookie for 30 days
    public function track_referral($referral_code) {
        setcookie('woonoow_ref', $referral_code, time() + (30 * DAY_IN_SECONDS));
    }
    
    // Record on order completion
    public function record_referral($order_id) {
        if (isset($_COOKIE['woonoow_ref'])) {
            // Get affiliate by code
            // Calculate commission
            // Create referral record
            // Clear cookie
        }
    }
}
```

#### 3. Admin UI
**Route**: `/marketing/affiliates`
- Affiliate list (name, code, referrals, earnings, status)
- Approve/reject affiliates
- Set commission rates
- View referral history
- Process payouts

#### 4. Customer Dashboard
**Route**: `/account/affiliate`
- Referral link & code
- Referral stats (clicks, conversions, earnings)
- Earnings breakdown (pending, approved, paid)
- Payout request form
- Referral history

#### 5. Notification Events
- `affiliate_application_approved`
- `affiliate_referral_completed`
- `affiliate_payout_processed`

### Priority: **Medium** 🟡
### Effort: 3-4 weeks

---

## 🔄 Module 5: Product Subscriptions

### Overview
Recurring product subscriptions with flexible billing cycles.

### Status: **Planning** 🔵

### What's Already Built
- ✅ Product management
- ✅ Order system
- ✅ Payment gateways
- ✅ Notification system

### What's Needed

#### 1. Database Tables
```sql
wp_woonoow_subscriptions (id, customer_id, product_id, status, billing_period, billing_interval, price, next_payment_date, start_date, end_date, trial_end_date)
wp_woonoow_subscription_orders (id, subscription_id, order_id, payment_status, created_at)
```

#### 2. Product Meta
Add subscription options to product:
- Is subscription product (checkbox)
- Billing period (daily, weekly, monthly, yearly)
- Billing interval (e.g., 2 for every 2 months)
- Trial period (days)

#### 3. Renewal System
```php
class SubscriptionRenewal {
    
    // WP-Cron daily job
    public function process_renewals() {
        $due_subscriptions = $this->get_due_subscriptions();
        
        foreach ($due_subscriptions as $subscription) {
            // Create renewal order
            // Process payment
            // Update next payment date
            // Send notification
        }
    }
}
```

#### 4. Customer Dashboard
**Route**: `/account/subscriptions`
- Active subscriptions list
- Pause/resume subscription
- Cancel subscription
- Update payment method
- View billing history
- Change billing cycle

#### 5. Admin UI
**Route**: `/products/subscriptions`
- All subscriptions list
- Filter by status
- View subscription details
- Manual renewal
- Cancel/refund

### Priority: **Low** 🟢
### Effort: 4-5 weeks

---

## 🔑 Module 6: Software Licensing

### Overview
License key generation, validation, and management for digital products.

### Status: **Planning** 🔵

### What's Already Built
- ✅ Product management
- ✅ Order system
- ✅ Customer management
- ✅ REST API infrastructure

### What's Needed

#### 1. Database Tables
```sql
wp_woonoow_licenses (id, license_key, product_id, order_id, customer_id, status, activations_limit, activations_count, expires_at, created_at)
wp_woonoow_license_activations (id, license_id, site_url, ip_address, user_agent, activated_at, deactivated_at)
```

#### 2. License Generation
```php
class LicenseGenerator {
    
    public function generate_license($order_id, $product_id) {
        // Generate unique key (XXXX-XXXX-XXXX-XXXX)
        // Get license settings from product meta
        // Create license record
        // Return license key
    }
}
```

#### 3. Validation API
```php
// Public API endpoint
POST /woonoow/v1/licenses/validate
{
  "license_key": "XXXX-XXXX-XXXX-XXXX",
  "site_url": "https://example.com"
}

Response:
{
  "valid": true,
  "license": {
    "key": "XXXX-XXXX-XXXX-XXXX",
    "product_id": 123,
    "expires_at": "2026-12-31",
    "activations_remaining": 3
  }
}
```

#### 4. Product Settings
Add licensing options to product:
- Licensed product (checkbox)
- Activation limit (number of sites)
- License duration (days, empty = lifetime)

#### 5. Customer Dashboard
**Route**: `/account/licenses`
- Active licenses list
- License key (copy button)
- Product name
- Activations (2/5 sites)
- Expiry date
- Manage activations (deactivate sites)
- Download product files

#### 6. Admin UI
**Route**: `/products/licenses`
- All licenses list
- Filter by status, product
- View license details
- View activations
- Revoke license
- Extend expiry
- Increase activation limit

### Priority: **Low** 🟢
### Effort: 3-4 weeks

---

## 📅 Implementation Timeline

### Phase 1: Foundation (Weeks 1-2)
- ✅ Module Registry System
- ✅ Settings UI for Modules
- ✅ Navigation Integration

### Phase 2: Newsletter Campaigns (Weeks 3-5)
- Database schema
- Campaign CRUD API
- Campaign UI (list, editor, preview)
- Sending system with batch processing
- Stats and reporting

### Phase 3: Wishlist Notifications (Weeks 6-7)
- Notification events registration
- Tracking system (price, stock, reminders)
- Email templates
- Settings UI
- WP-Cron jobs

### Phase 4: Affiliate Program (Weeks 8-11)
- Database schema
- Tracking system (cookies, referrals)
- Admin UI (affiliates, payouts)
- Customer dashboard
- Notification events

### Phase 5: Subscriptions (Weeks 12-16)
- Database schema
- Product subscription options
- Renewal system
- Customer dashboard
- Admin management UI

### Phase 6: Licensing (Weeks 17-20)
- Database schema
- License generation
- Validation API
- Customer dashboard
- Admin management UI

---

## 🎯 Success Metrics

### Newsletter Campaigns
- Campaign creation time < 5 minutes
- Email delivery rate > 95%
- Batch processing handles 10,000+ subscribers
- Zero duplicate sends

### Wishlist Notifications
- Notification delivery within 1 hour of trigger
- Price drop detection accuracy 100%
- Stock status sync < 5 minutes
- Reminder delivery on schedule

### Affiliate Program
- Referral tracking accuracy 100%
- Commission calculation accuracy 100%
- Payout processing < 24 hours
- Dashboard load time < 2 seconds

### Subscriptions
- Renewal success rate > 95%
- Payment retry on failure (3 attempts)
- Customer cancellation < 3 clicks
- Billing accuracy 100%

### Licensing
- License validation response < 500ms
- Activation tracking accuracy 100%
- Zero false positives on validation
- Deactivation sync < 1 minute

---

## 🔧 Technical Considerations

### Performance
- Cache module states (transients)
- Index database tables properly
- Batch process large operations
- Use WP-Cron for scheduled tasks

### Security
- Validate all API inputs
- Sanitize user data
- Use nonces for forms
- Encrypt sensitive data (license keys, API keys)

### Scalability
- Support 100,000+ subscribers (newsletter)
- Support 10,000+ affiliates
- Support 50,000+ subscriptions
- Support 100,000+ licenses

### Compatibility
- WordPress 6.0+
- WooCommerce 8.0+
- PHP 7.4+
- MySQL 5.7+

---

## 📚 Documentation Needs

For each module, create:
1. **User Guide** - How to use the feature
2. **Developer Guide** - Hooks, filters, API endpoints
3. **Admin Guide** - Configuration and management
4. **Migration Guide** - Importing from other plugins

---

## 🚀 Next Steps

1. **Review and approve** this roadmap
2. **Prioritize modules** based on business needs
3. **Start with Module 1** (Module Management System)
4. **Implement Phase 1** (Foundation)
5. **Iterate and gather feedback**

---

## 📝 Notes

- All modules leverage existing notification system
- All modules use existing email builder
- All modules follow addon bridge pattern
- All modules have enable/disable toggle
- All modules are SPA-first with React UI
