Files
WooNooW/includes/Api/Routes.php
dwindown b405fd49cc feat: Add Store Settings backend with full countries/timezones
 StoreSettingsProvider.php:
- get_countries() - All WooCommerce countries
- get_timezones() - All PHP timezones with UTC offsets
- get_currencies() - All WooCommerce currencies with symbols
- get_settings() - Current store settings
- save_settings() - Save store settings

 StoreController.php:
- GET /woonoow/v1/store/settings
- POST /woonoow/v1/store/settings
- GET /woonoow/v1/store/countries (200+ countries)
- GET /woonoow/v1/store/timezones (400+ timezones)
- GET /woonoow/v1/store/currencies (100+ currencies)
- Response caching (1 hour for static data)

🔌 Integration:
- Registered in Api/Routes.php
- Permission checks (manage_woocommerce)
- Error handling

Next: Update Store.tsx to use real API
2025-11-05 22:08:53 +07:00

55 lines
1.9 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;
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();
});
}
}