Files
WooNooW/includes/Modules/Affiliate/AffiliateSettings.php

102 lines
4.1 KiB
PHP

<?php
/**
* Affiliate Module Settings Schema
*
* Defines the settings schema for the Affiliate module.
*
* @package WooNooW\Modules\Affiliate
*/
namespace WooNooW\Modules\Affiliate;
class AffiliateSettings {
public static function init() {
// Register settings schema
add_filter('woonoow/module_settings_schema', [__CLASS__, 'register_schema']);
}
/**
* Register affiliate settings schema
*/
public static function register_schema($schemas) {
$schemas['affiliate'] = [
'woonoow_affiliate_default_rate' => [
'type' => 'number',
'label' => __('Default Commission Rate (%)', 'woonoow'),
'description' => __('The default commission rate percentage for affiliates.', 'woonoow'),
'placeholder' => '10',
'default' => 10,
'min' => 0,
'max' => 100,
],
'woonoow_affiliate_holding_period' => [
'type' => 'number',
'label' => __('Holding Period (Days)', 'woonoow'),
'description' => __('Number of days before a referral becomes eligible for payout (e.g. to account for refunds). Set to 0 for immediate approval on order completion.', 'woonoow'),
'placeholder' => '14',
'default' => 14,
'min' => 0,
],
'woonoow_affiliate_payment_methods' => [
'type' => 'multiselect',
'label' => __('Available Payment Methods', 'woonoow'),
'description' => __('Select which payment methods affiliates can use to receive payouts.', 'woonoow'),
'options' => [
'bank_transfer' => __('Bank Transfer', 'woonoow'),
'paypal' => __('PayPal', 'woonoow'),
'wise' => __('Wise', 'woonoow'),
'skrill' => __('Skrill', 'woonoow'),
'payoneer' => __('Payoneer', 'woonoow'),
'custom' => __('Custom (Notes)', 'woonoow'),
],
'default' => ['bank_transfer'],
],
'woonoow_affiliate_auto_approve' => [
'type' => 'toggle',
'label' => __('Auto-Approve Affiliates', 'woonoow'),
'description' => __('Automatically approve new affiliate applications.', 'woonoow'),
'default' => false,
],
'woonoow_affiliate_enable_curated_collections' => [
'type' => 'toggle',
'label' => __('Enable Curated Collections', 'woonoow'),
'description' => __('Allow affiliates to create and share custom curated product collections.', 'woonoow'),
'default' => true,
],
'woonoow_affiliate_allow_self_referral' => [
'type' => 'toggle',
'label' => __('Allow Self-Referrals', 'woonoow'),
'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);
}
}