feat: Coupons CRUD - Backend API (Phase 1)
Implemented CouponsController with full CRUD operations
Created: CouponsController.php
- GET /coupons - List coupons with pagination and filtering
- GET /coupons/{id} - Get single coupon
- POST /coupons - Create new coupon
- PUT /coupons/{id} - Update coupon
- DELETE /coupons/{id} - Delete coupon
Features:
- Pagination support (page, per_page)
- Search by coupon code
- Filter by discount_type
- Full coupon data (all WooCommerce fields)
- Validation (code required, duplicate check)
- Error handling (user-friendly messages)
Coupon Fields Supported:
- Basic: code, amount, discount_type, description
- Usage: usage_count, usage_limit, usage_limit_per_user
- Restrictions: product_ids, categories, email_restrictions
- Limits: minimum_amount, maximum_amount, date_expires
- Options: individual_use, free_shipping, exclude_sale_items
Registered in Routes.php:
- Added CouponsController to route registration
- Follows API_ROUTES.md standards
Following PROJECT_SOP.md:
- Consistent error responses
- Permission checks (manage_woocommerce)
- User-friendly error messages
- Standard REST patterns
Next Steps:
- Frontend list page with submenu tabs
- Frontend create/edit form
- Update API_ROUTES.md
- Update NavigationRegistry.php
This commit is contained in:
@@ -18,6 +18,7 @@ use WooNooW\Api\SystemController;
|
||||
use WooNooW\Api\NotificationsController;
|
||||
use WooNooW\Api\ActivityLogController;
|
||||
use WooNooW\Api\ProductsController;
|
||||
use WooNooW\Api\CouponsController;
|
||||
|
||||
class Routes {
|
||||
public static function init() {
|
||||
@@ -108,6 +109,9 @@ class Routes {
|
||||
error_log('WooNooW Routes: Registering ProductsController routes');
|
||||
ProductsController::register_routes();
|
||||
error_log('WooNooW Routes: ProductsController routes registered');
|
||||
|
||||
// Coupons controller
|
||||
CouponsController::register_routes();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user