Files
Odoo-Modules/fusion-woo-odoo/fusion-woodoo/CLAUDE.md
gsinghpal 8b723086b9 docs: add CLAUDE.md for both fusion_woocommerce and fusion-woodoo
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-01 01:02:21 -04:00

69 lines
3.2 KiB
Markdown

# Fusion WooDoo — WordPress Plugin
## What This Is
Thin WordPress/WooCommerce plugin that pairs with the `fusion_woocommerce` Odoo module. Receives data from Odoo, displays documents in the customer My Account portal, and fires webhooks to notify Odoo of WC events.
## Architecture
- **Receives from Odoo**: REST endpoints accept order status, invoices, deliveries, messages
- **Sends to Odoo**: WooCommerce webhooks fire on order/product/customer events
- **Displays to customers**: My Account tabs for sales orders, invoices, deliveries, returns, order timeline
## Key Files
```
fusion-woodoo.php — Plugin entry, activation/deactivation hooks
includes/class-fusion-woodoo.php — Singleton main class, loads all includes
includes/class-admin-settings.php — WP admin settings (Odoo URL, API key, toggles)
includes/class-rest-endpoints.php — REST API endpoints (receive from Odoo)
includes/class-webhooks.php — WC webhook registration/lifecycle
includes/class-my-account.php — My Account tab registration
includes/class-order-timeline.php — Visual order status timeline
includes/class-returns.php — Return/RMA request handling
includes/class-api-client.php — PHP client for calling Odoo API
templates/my-account/ — Customer portal templates
assets/css/my-account.css — Portal styles
assets/js/my-account.js — Portal JS (AJAX, reorder, returns)
```
## Authentication
- **Odoo → WP plugin**: Odoo API key as bearer token in Authorization header
- **WP plugin → Odoo**: Not direct — uses WC webhooks which Odoo validates via HMAC
## PDF Storage
- Invoices: `wp-content/uploads/fusion-woodoo/invoices/` (`.htaccess` protected)
- Deliveries: `wp-content/uploads/fusion-woodoo/deliveries/` (`.htaccess` protected)
- Served via PHP handler that validates user owns the order
## WordPress Options
- `fusion_woodoo_odoo_url` — Odoo instance URL
- `fusion_woodoo_api_key` — API key for Odoo auth
- `fusion_woodoo_show_sales_orders` — Toggle sales orders tab
- `fusion_woodoo_show_invoices` — Toggle invoices tab
- `fusion_woodoo_show_deliveries` — Toggle deliveries tab
- `fusion_woodoo_show_returns` — Toggle returns tab
## WooCommerce Order Meta Keys
- `_odoo_order_id`, `_odoo_invoice_id` — Linked Odoo record IDs
- `_odoo_invoice_pdf`, `_odoo_delivery_pdf` — PDF file paths
- `_odoo_tracking_number`, `_odoo_shipping_carrier` — Shipping info
- `_odoo_order_status` — Status for timeline display
- `_odoo_messages` — JSON array of customer-visible messages
## Deployment
```bash
# Deploy to westin WordPress
sshpass -p '9896924728Kk@@##' scp -r fusion-woo-odoo/fusion-woodoo/* westin@192.168.1.152:/tmp/fusion-woodoo/
sshpass -p '9896924728Kk@@##' ssh westin@192.168.1.152 "echo '9896924728Kk@@##' | sudo -S cp -r /tmp/fusion-woodoo/* /home/westinwp/htdocs/westinhealthcare.ca/wp-content/plugins/fusion-woodoo/"
```
## Webhook Lifecycle
- Registered on plugin activation / settings save
- Unregistered on plugin deactivation
- Re-registered when Odoo URL changes
- Topics: order.created, order.updated, product.updated, customer.created, customer.updated
## Requirements
- WordPress 6.0+
- WooCommerce 8.0+
- PHP 8.0+
- Odoo 19 with fusion_woocommerce module installed