# WooNooW Addon & Module Development Guide **Version:** 2.0.0 **Status:** Production Ready This document is the single source of truth for extending WooNooW. It covers everything from basic code snippets (Bridge Patterns) to full-featured React SPAs (Addon Modules). --- ## 📋 Table of Contents 1. [Philosophy & Architecture](#philosophy--architecture) 2. [Addon Types & Integration Levels](#addon-types--integration-levels) - Level 1: Vanilla JS / Bridge Patterns - Level 2: React Runtime Expansion (Recommended) - Level 3: Slot-Based Components 3. [Developing a Full Addon](#developing-a-full-addon) - Registration - Settings & Options - The Hook System 4. [Addon & Built-in Module Unification](#addon--built-in-module-unification) 5. [Examples](#examples) --- ## 1. Philosophy & Architecture **WooNooW Core = Zero Addon Dependencies** We don't integrate specific addons (like shipping or payment plugins) directly into WooNooW core. Instead, we provide: 1. **Hook system** for external addons to extend functionality. 2. **Exposed React Runtime** so addons don't have to bundle heavy libraries. 3. **Unified Module Registry** where built-in features (like Affiliates, Newsletters) and external addons share the same UI and enablement toggles. --- ## 2. Addon Types & Integration Levels ### Level 1: Vanilla JS / Bridge Patterns (Basic) Use this for simple snippets to make existing WooCommerce plugins (e.g. Rajaongkir) work with WooNooW. ```javascript // Wait for WooNooW to load window.addEventListener('woonoow:loaded', function() { window.WooNooW.hooks.addFilter('woonoow_order_form_after_shipping', function(container, formData) { const div = document.createElement('div'); div.innerHTML = ``; container.appendChild(div); return container; }); }); ``` ### Level 2: Exposed React Runtime (Recommended) WooNooW exposes `React`, `ReactDOM`, its `hooks`, and its `components` on `window.WooNooW`. This allows addons to build rich UIs without bundling React. **Webpack/Vite Setup (Externals):** ```javascript // vite.config.js export default { build: { rollupOptions: { external: ['react', 'react-dom'], output: { globals: { react: 'window.WooNooW.React', 'react-dom': 'window.WooNooW.ReactDOM' } } } } }; ``` **Usage:** ```typescript const { React, hooks, components } = window.WooNooW; const { addFilter } = hooks; const { Select } = components; function CustomField({ formData, setFormData }) { return