## 1. Created BITESHIP_ADDON_SPEC.md ✅ - Complete plugin specification - Database schema, API endpoints - WooCommerce integration - React components - Implementation timeline ## 2. Merged Addon Documentation ✅ Created ADDON_DEVELOPMENT_GUIDE.md (single source of truth): - Merged ADDON_INJECTION_GUIDE.md + ADDON_HOOK_SYSTEM.md - Two addon types: Route Injection + Hook System - Clear examples for each type - Best practices and troubleshooting - Deleted old documents ## 3. Tax Settings ✅ Frontend (admin-spa/src/routes/Settings/Tax.tsx): - Enable/disable tax calculation toggle - Display standard/reduced/zero tax rates - Show tax options (prices include tax, based on, display) - Link to WooCommerce for advanced config - Clean, simple UI Backend (includes/Api/TaxController.php): - GET /settings/tax - Fetch tax settings - POST /settings/tax/toggle - Enable/disable taxes - Fetches rates from woocommerce_tax_rates table - Clears WooCommerce cache on update ## 4. Advanced Local Pickup - TODO Will be simple: Admin adds multiple pickup locations ## Key Decisions: ✅ Hook system = No hardcoding, zero coupling ✅ Tax settings = Simple toggle + view, advanced in WC ✅ Single addon guide = One source of truth Next: Advanced Local Pickup locations
65 lines
2.3 KiB
PHP
65 lines
2.3 KiB
PHP
<?php
|
|
namespace WooNooW\Api;
|
|
|
|
use WP_REST_Request;
|
|
use WP_REST_Response;
|
|
use WooNooW\Api\CheckoutController;
|
|
use WooNooW\Api\OrdersController;
|
|
use WooNooW\Api\AnalyticsController;
|
|
use WooNooW\Api\AuthController;
|
|
use WooNooW\API\PaymentsController;
|
|
use WooNooW\API\StoreController;
|
|
use WooNooW\Api\ShippingController;
|
|
use WooNooW\Api\TaxController;
|
|
|
|
class Routes {
|
|
public static function init() {
|
|
// Initialize controllers (register action hooks)
|
|
OrdersController::init();
|
|
|
|
add_action('rest_api_init', function () {
|
|
$namespace = 'woonoow/v1';
|
|
|
|
// Auth endpoints (public - no permission check)
|
|
register_rest_route( $namespace, '/auth/login', [
|
|
'methods' => 'POST',
|
|
'callback' => [ AuthController::class, 'login' ],
|
|
'permission_callback' => '__return_true',
|
|
] );
|
|
|
|
register_rest_route( $namespace, '/auth/logout', [
|
|
'methods' => 'POST',
|
|
'callback' => [ AuthController::class, 'logout' ],
|
|
'permission_callback' => '__return_true',
|
|
] );
|
|
|
|
register_rest_route( $namespace, '/auth/check', [
|
|
'methods' => 'GET',
|
|
'callback' => [ AuthController::class, 'check' ],
|
|
'permission_callback' => '__return_true',
|
|
] );
|
|
|
|
// Defer to controllers to register their endpoints
|
|
CheckoutController::register();
|
|
OrdersController::register();
|
|
AnalyticsController::register_routes();
|
|
|
|
// Payments controller
|
|
$payments_controller = new PaymentsController();
|
|
$payments_controller->register_routes();
|
|
|
|
// Store controller
|
|
$store_controller = new StoreController();
|
|
$store_controller->register_routes();
|
|
|
|
// Shipping controller
|
|
$shipping_controller = new ShippingController();
|
|
$shipping_controller->register_routes();
|
|
|
|
// Tax controller
|
|
$tax_controller = new TaxController();
|
|
$tax_controller->register_routes();
|
|
});
|
|
}
|
|
}
|