Affiliate module: fix referral approval lifecycle and settings reads

This commit is contained in:
Dwindi Ramadhana
2026-06-02 00:37:20 +07:00
parent f3c4ee7124
commit fec786daa6
8 changed files with 344 additions and 36 deletions

View File

@@ -64,8 +64,32 @@ class AffiliateSettings {
'description' => __('Allow affiliates to earn commission when their own user account places an order.', 'woonoow'),
'default' => false,
],
'woonoow_affiliate_share_customer_data' => [
'type' => 'toggle',
'label' => __('Share Customer Data with Affiliates', 'woonoow'),
'description' => __('Allow affiliates to see the name and email of the customers they refer.', 'woonoow'),
'default' => false,
],
];
return $schemas;
}
/**
* Read Affiliate module setting from module settings storage with legacy fallback.
*
* @param string $key
* @param mixed $default
* @return mixed
*/
public static function get_setting($key, $default = null)
{
$module_settings = get_option('woonoow_module_affiliate_settings', []);
if (is_array($module_settings) && array_key_exists($key, $module_settings)) {
return $module_settings[$key];
}
// Legacy fallback for older installs that may store direct option keys.
return get_option($key, $default);
}
}