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:
@@ -39,46 +39,49 @@ class CustomerSettingsProvider {
|
||||
* @return bool
|
||||
*/
|
||||
public static function update_settings($settings) {
|
||||
$updated = true;
|
||||
|
||||
// General settings
|
||||
if (isset($settings['auto_register_members'])) {
|
||||
$updated = $updated && update_option('woonoow_auto_register_members', $settings['auto_register_members'] ? 'yes' : 'no');
|
||||
if (array_key_exists('auto_register_members', $settings)) {
|
||||
$value = !empty($settings['auto_register_members']) ? 'yes' : 'no';
|
||||
update_option('woonoow_auto_register_members', $value);
|
||||
}
|
||||
|
||||
if (isset($settings['multiple_addresses_enabled'])) {
|
||||
$updated = $updated && update_option('woonoow_multiple_addresses_enabled', $settings['multiple_addresses_enabled'] ? 'yes' : 'no');
|
||||
if (array_key_exists('multiple_addresses_enabled', $settings)) {
|
||||
$value = !empty($settings['multiple_addresses_enabled']) ? 'yes' : 'no';
|
||||
update_option('woonoow_multiple_addresses_enabled', $value);
|
||||
}
|
||||
|
||||
if (isset($settings['wishlist_enabled'])) {
|
||||
$updated = $updated && update_option('woonoow_wishlist_enabled', $settings['wishlist_enabled'] ? 'yes' : 'no');
|
||||
if (array_key_exists('wishlist_enabled', $settings)) {
|
||||
$value = !empty($settings['wishlist_enabled']) ? 'yes' : 'no';
|
||||
update_option('woonoow_wishlist_enabled', $value);
|
||||
}
|
||||
|
||||
// VIP settings
|
||||
if (isset($settings['vip_min_spent'])) {
|
||||
$updated = $updated && update_option('woonoow_vip_min_spent', floatval($settings['vip_min_spent']));
|
||||
update_option('woonoow_vip_min_spent', floatval($settings['vip_min_spent']));
|
||||
}
|
||||
|
||||
if (isset($settings['vip_min_orders'])) {
|
||||
$updated = $updated && update_option('woonoow_vip_min_orders', intval($settings['vip_min_orders']));
|
||||
update_option('woonoow_vip_min_orders', intval($settings['vip_min_orders']));
|
||||
}
|
||||
|
||||
if (isset($settings['vip_timeframe'])) {
|
||||
$timeframe = in_array($settings['vip_timeframe'], ['all', '30', '90', '365'])
|
||||
? $settings['vip_timeframe']
|
||||
: 'all';
|
||||
$updated = $updated && update_option('woonoow_vip_timeframe', $timeframe);
|
||||
update_option('woonoow_vip_timeframe', $timeframe);
|
||||
}
|
||||
|
||||
if (isset($settings['vip_require_both'])) {
|
||||
$updated = $updated && update_option('woonoow_vip_require_both', $settings['vip_require_both'] ? 'yes' : 'no');
|
||||
if (array_key_exists('vip_require_both', $settings)) {
|
||||
$value = !empty($settings['vip_require_both']) ? 'yes' : 'no';
|
||||
update_option('woonoow_vip_require_both', $value);
|
||||
}
|
||||
|
||||
if (isset($settings['vip_exclude_refunded'])) {
|
||||
$updated = $updated && update_option('woonoow_vip_exclude_refunded', $settings['vip_exclude_refunded'] ? 'yes' : 'no');
|
||||
if (array_key_exists('vip_exclude_refunded', $settings)) {
|
||||
$value = !empty($settings['vip_exclude_refunded']) ? 'yes' : 'no';
|
||||
update_option('woonoow_vip_exclude_refunded', $value);
|
||||
}
|
||||
|
||||
return $updated;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user