feat: Newsletter system improvements and validation framework
- Fix: Marketing events now display in Staff notifications tab - Reorganize: Move Coupons to Marketing/Coupons for better organization - Add: Comprehensive email/phone validation with extensible filter hooks - Email validation with regex pattern (xxxx@xxxx.xx) - Phone validation with WhatsApp verification support - Filter hooks for external API integration (QuickEmailVerification, etc.) - Fix: Newsletter template routes now use centralized notification email builder - Add: Validation.php class for reusable validation logic - Add: VALIDATION_HOOKS.md documentation with integration examples - Add: NEWSLETTER_CAMPAIGN_PLAN.md architecture for future campaign system - Fix: API delete method call in Newsletter.tsx (delete -> del) - Remove: Duplicate EmailTemplates.tsx (using notification system instead) - Update: Newsletter controller to use centralized Validation class Breaking changes: - Coupons routes moved from /routes/Coupons to /routes/Marketing/Coupons - Legacy /coupons routes maintained for backward compatibility
This commit is contained in:
@@ -68,19 +68,12 @@ class ProductsController {
|
||||
* Register REST API routes
|
||||
*/
|
||||
public static function register_routes() {
|
||||
error_log('WooNooW ProductsController::register_routes() START');
|
||||
|
||||
// List products
|
||||
$callback = [__CLASS__, 'get_products'];
|
||||
$is_callable = is_callable($callback);
|
||||
error_log('WooNooW ProductsController: Callback is_callable: ' . ($is_callable ? 'YES' : 'NO'));
|
||||
|
||||
$result = register_rest_route('woonoow/v1', '/products', [
|
||||
register_rest_route('woonoow/v1', '/products', [
|
||||
'methods' => 'GET',
|
||||
'callback' => $callback,
|
||||
'callback' => [__CLASS__, 'get_products'],
|
||||
'permission_callback' => [Permissions::class, 'check_admin_permission'],
|
||||
]);
|
||||
error_log('WooNooW ProductsController: GET /products registered: ' . ($result ? 'SUCCESS' : 'FAILED'));
|
||||
|
||||
// Get single product
|
||||
register_rest_route('woonoow/v1', '/products/(?P<id>\d+)', [
|
||||
@@ -136,8 +129,6 @@ class ProductsController {
|
||||
* Get products list with filters
|
||||
*/
|
||||
public static function get_products(WP_REST_Request $request) {
|
||||
error_log('WooNooW ProductsController::get_products() CALLED - START');
|
||||
|
||||
try {
|
||||
$page = max(1, (int) $request->get_param('page'));
|
||||
$per_page = min(100, max(1, (int) ($request->get_param('per_page') ?: 20)));
|
||||
@@ -206,12 +197,7 @@ class ProductsController {
|
||||
foreach ($query->posts as $post) {
|
||||
$product = wc_get_product($post->ID);
|
||||
if ($product) {
|
||||
$formatted = self::format_product_list_item($product);
|
||||
// Debug: Log first product to verify structure
|
||||
if (empty($products)) {
|
||||
error_log('WooNooW Debug - First product data: ' . print_r($formatted, true));
|
||||
}
|
||||
$products[] = $formatted;
|
||||
$products[] = self::format_product_list_item($product);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -228,14 +214,10 @@ class ProductsController {
|
||||
$response->header('Cache-Control', 'no-cache, no-store, must-revalidate');
|
||||
$response->header('Pragma', 'no-cache');
|
||||
$response->header('Expires', '0');
|
||||
$response->header('X-WooNooW-Version', '2.0'); // Debug header
|
||||
|
||||
error_log('WooNooW ProductsController::get_products() CALLED - END SUCCESS');
|
||||
return $response;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
error_log('WooNooW ProductsController::get_products() ERROR: ' . $e->getMessage());
|
||||
error_log('WooNooW ProductsController::get_products() TRACE: ' . $e->getTraceAsString());
|
||||
return new WP_Error('products_error', $e->getMessage(), ['status' => 500]);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user