| @@ -5,17 +5,52 @@ | ||
| 5 | 5 | use FluentBooking\Framework\Support\Arr; |
| 6 | 6 | |
| 7 | 7 | class CurrenciesHelper |
| 8 | 8 | { |
| 9 | + private static $globalCurrencySettings = null; | |
| 10 | + | |
| 11 | + public static function getDefaultCurrencySettings() | |
| 12 | + { | |
| 13 | + return apply_filters('fluent_booking/default_currency_settings', [ | |
| 14 | + 'currency' => 'USD', | |
| 15 | + 'is_active' => 'no', | |
| 16 | + 'currency_sign' => '$', | |
| 17 | + 'currency_position' => 'left', // left, right, left_space, right_space | |
| 18 | + 'number_format' => 'comma_separated', // or dot_separated | |
| 19 | + 'decimal_points' => 2 | |
| 20 | + ]); | |
| 21 | + } | |
| 22 | + | |
| 23 | + public static function getGlobalCurrencySettings($force = false) | |
| 24 | + { | |
| 25 | + if (!$force && self::$globalCurrencySettings !== null) { | |
| 26 | + return self::$globalCurrencySettings; | |
| 27 | + } | |
| 28 | + | |
| 29 | + $defaultSettings = self::getDefaultCurrencySettings(); | |
| 30 | + | |
| 31 | + $globalSettings = Helper::getGlobalPaymentSettings(); | |
| 32 | + | |
| 33 | + $currencySettings = wp_parse_args($globalSettings, $defaultSettings); | |
| 34 | + | |
| 35 | + $currencySettings['currency_sign'] = self::getCurrencySign($currencySettings['currency']); | |
| 36 | + | |
| 37 | + self::$globalCurrencySettings = apply_filters('fluent_booking/global_currency_settings', $currencySettings); | |
| 38 | + | |
| 39 | + return self::$globalCurrencySettings; | |
| 40 | + } | |
| 41 | + | |
| 9 | 42 | public static function getGlobalCurrency() |
| 10 | 43 | { |
| 11 | - $globalPaymentSettings = get_option('fluent_booking_global_payment_settings', ['currency' => 'USD']); | |
| 12 | - return Arr::get($globalPaymentSettings, 'currency', 'USD'); | |
| 44 | + $globalCurrencySettings = self::getGlobalCurrencySettings(); | |
| 45 | + | |
| 46 | + return Arr::get($globalCurrencySettings, 'currency', 'USD'); | |
| 13 | 47 | } |
| 14 | 48 | |
| 15 | 49 | public static function getGlobalCurrencySign() |
| 16 | 50 | { |
| 17 | 51 | $currency = static::getGlobalCurrency(); |
| 52 | + | |
| 18 | 53 | return static::getCurrencySign($currency); |
| 19 | 54 | } |
| 20 | 55 | |
| 21 | 56 | public static function getFormattedCurrencies() |
| @@ -342,8 +377,9 @@ | ||
| 342 | 377 | 'SOS' => 'Sh', |
| 343 | 378 | 'SRD' => '$', |
| 344 | 379 | 'SSP' => '£', |
| 345 | 380 | 'STD' => 'Db', |
| 381 | + 'SVC' => '₡', | |
| 346 | 382 | 'SYP' => 'ل.س', |
| 347 | 383 | 'SZL' => 'L', |
| 348 | 384 | 'THB' => '฿', |
| 349 | 385 | 'TJS' => 'ЅМ', |