| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentCart\App\Helpers; |
| 4 |
|
| 5 |
use FluentCart\Api\CurrencySettings; |
| 6 |
use FLuentCart\Framework\Support\Arr; |
| 7 |
|
| 8 |
if (!defined('ABSPATH')) { |
| 9 |
exit; |
| 10 |
} |
| 11 |
|
| 12 |
|
| 13 |
class CurrenciesHelper |
| 14 |
{ |
| 15 |
/** |
| 16 |
* https://support.stripe.com/questions/which-currencies-does-stripe-support |
| 17 |
*/ |
| 18 |
public static function getCurrencies($code = null) |
| 19 |
{ |
| 20 |
$currencies = apply_filters('fluent_cart/accepted_currencies', array( |
| 21 |
'AED' => __('United Arab Emirates Dirham', 'fluent-cart'), |
| 22 |
'AFN' => __('Afghan Afghani', 'fluent-cart'), |
| 23 |
'ALL' => __('Albanian Lek', 'fluent-cart'), |
| 24 |
'AMD' => __('Armenian Dram', 'fluent-cart'), |
| 25 |
'ANG' => __('Netherlands Antillean Gulden', 'fluent-cart'), |
| 26 |
'AOA' => __('Angolan Kwanza', 'fluent-cart'), |
| 27 |
'ARS' => __('Argentine Peso', 'fluent-cart'), // non amex |
| 28 |
'AUD' => __('Australian Dollar', 'fluent-cart'), |
| 29 |
'AWG' => __('Aruban Florin', 'fluent-cart'), |
| 30 |
'AZN' => __('Azerbaijani Manat', 'fluent-cart'), |
| 31 |
'BAM' => __('Bosnia & Herzegovina Convertible Mark', 'fluent-cart'), |
| 32 |
'BBD' => __('Barbadian Dollar', 'fluent-cart'), |
| 33 |
'BDT' => __('Bangladeshi Taka', 'fluent-cart'), |
| 34 |
'BIF' => __('Burundian Franc', 'fluent-cart'), |
| 35 |
'BGN' => __('Bulgarian Lev', 'fluent-cart'), |
| 36 |
'BMD' => __('Bermudian Dollar', 'fluent-cart'), |
| 37 |
'BND' => __('Brunei Dollar', 'fluent-cart'), |
| 38 |
'BOB' => __('Bolivian Boliviano', 'fluent-cart'), |
| 39 |
'BRL' => __('Brazilian Real', 'fluent-cart'), |
| 40 |
'BSD' => __('Bahamian Dollar', 'fluent-cart'), |
| 41 |
'BWP' => __('Botswana Pula', 'fluent-cart'), |
| 42 |
'BYN' => __('Belarusian Ruble', 'fluent-cart'), |
| 43 |
'BZD' => __('Belize Dollar', 'fluent-cart'), |
| 44 |
'CAD' => __('Canadian Dollar', 'fluent-cart'), |
| 45 |
'CDF' => __('Congolese Franc', 'fluent-cart'), |
| 46 |
'CHF' => __('Swiss Franc', 'fluent-cart'), |
| 47 |
'CLP' => __('Chilean Peso', 'fluent-cart'), |
| 48 |
'CNY' => __('Chinese Renminbi Yuan', 'fluent-cart'), |
| 49 |
'COP' => __('Colombian Peso', 'fluent-cart'), |
| 50 |
'CRC' => __('Costa Rican Colón', 'fluent-cart'), |
| 51 |
'CVE' => __('Cape Verdean Escudo', 'fluent-cart'), |
| 52 |
'CZK' => __('Czech Koruna', 'fluent-cart'), |
| 53 |
'DJF' => __('Djiboutian Franc', 'fluent-cart'), |
| 54 |
'DKK' => __('Danish Krone', 'fluent-cart'), |
| 55 |
'DOP' => __('Dominican Peso', 'fluent-cart'), |
| 56 |
'DZD' => __('Algerian Dinar', 'fluent-cart'), |
| 57 |
'EGP' => __('Egyptian Pound', 'fluent-cart'), |
| 58 |
'ETB' => __('Ethiopian Birr', 'fluent-cart'), |
| 59 |
'EUR' => __('Euro', 'fluent-cart'), |
| 60 |
'FJD' => __('Fijian Dollar', 'fluent-cart'), |
| 61 |
'FKP' => __('Falkland Islands Pound', 'fluent-cart'), |
| 62 |
'GBP' => __('British Pound', 'fluent-cart'), |
| 63 |
'GEL' => __('Georgian Lari', 'fluent-cart'), |
| 64 |
'GHS' => __('Ghanaian Cedi', 'fluent-cart'), |
| 65 |
'GIP' => __('Gibraltar Pound', 'fluent-cart'), |
| 66 |
'GMD' => __('Gambian Dalasi', 'fluent-cart'), |
| 67 |
'GNF' => __('Guinean Franc', 'fluent-cart'), |
| 68 |
'GTQ' => __('Guatemalan Quetzal', 'fluent-cart'), |
| 69 |
'GYD' => __('Guyanese Dollar', 'fluent-cart'), |
| 70 |
'HKD' => __('Hong Kong Dollar', 'fluent-cart'), |
| 71 |
'HNL' => __('Honduran Lempira', 'fluent-cart'), |
| 72 |
'HRK' => __('Croatian Kuna', 'fluent-cart'), |
| 73 |
'HTG' => __('Haitian Gourde', 'fluent-cart'), |
| 74 |
'HUF' => __('Hungarian Forint', 'fluent-cart'), |
| 75 |
'IDR' => __('Indonesian Rupiah', 'fluent-cart'), |
| 76 |
'ILS' => __('Israeli New Sheqel', 'fluent-cart'), |
| 77 |
'INR' => __('Indian Rupee', 'fluent-cart'), |
| 78 |
'IRR' => __('Iranian Rial', 'fluent-cart'), |
| 79 |
'ISK' => __('Icelandic Króna', 'fluent-cart'), |
| 80 |
'JMD' => __('Jamaican Dollar', 'fluent-cart'), |
| 81 |
'JPY' => __('Japanese Yen', 'fluent-cart'), |
| 82 |
'KES' => __('Kenyan Shilling', 'fluent-cart'), |
| 83 |
'KGS' => __('Kyrgyzstani Som', 'fluent-cart'), |
| 84 |
'KHR' => __('Cambodian Riel', 'fluent-cart'), |
| 85 |
'KMF' => __('Comorian Franc', 'fluent-cart'), |
| 86 |
'KRW' => __('South Korean Won', 'fluent-cart'), |
| 87 |
'KYD' => __('Cayman Islands Dollar', 'fluent-cart'), |
| 88 |
'KZT' => __('Kazakhstani Tenge', 'fluent-cart'), |
| 89 |
'LAK' => __('Lao Kip', 'fluent-cart'), |
| 90 |
'LBP' => __('Lebanese Pound', 'fluent-cart'), |
| 91 |
'LKR' => 'Sri Lankan Rupee', |
| 92 |
'LRD' => __('Liberian Dollar', 'fluent-cart'), |
| 93 |
'LSL' => __('Lesotho Loti', 'fluent-cart'), |
| 94 |
'MAD' => __('Moroccan Dirham', 'fluent-cart'), |
| 95 |
'MDL' => __('Moldovan Leu', 'fluent-cart'), |
| 96 |
'MGA' => __('Malagasy Ariary', 'fluent-cart'), |
| 97 |
'MKD' => __('Macedonian Denar', 'fluent-cart'), |
| 98 |
'MMK' => __('Myanmar Kyat', 'fluent-cart'), |
| 99 |
'MNT' => __('Mongolian Tögrög', 'fluent-cart'), |
| 100 |
'MOP' => __('Macanese Pataca', 'fluent-cart'), |
| 101 |
'MRO' => __('Mauritanian Ouguiya', 'fluent-cart'), |
| 102 |
'MUR' => __('Mauritian Rupee', 'fluent-cart'), |
| 103 |
'MVR' => __('Maldivian Rufiyaa', 'fluent-cart'), |
| 104 |
'MWK' => __('Malawian Kwacha', 'fluent-cart'), |
| 105 |
'MXN' => __('Mexican Peso', 'fluent-cart'), |
| 106 |
'MYR' => __('Malaysian Ringgit', 'fluent-cart'), |
| 107 |
'MZN' => __('Mozambican Metical', 'fluent-cart'), |
| 108 |
'NAD' => __('Namibian Dollar', 'fluent-cart'), |
| 109 |
'NGN' => __('Nigerian Naira', 'fluent-cart'), |
| 110 |
'NIO' => __('Nicaraguan Córdoba', 'fluent-cart'), |
| 111 |
'NOK' => __('Norwegian Krone', 'fluent-cart'), |
| 112 |
'NPR' => __('Nepalese Rupee', 'fluent-cart'), |
| 113 |
'NZD' => __('New Zealand Dollar', 'fluent-cart'), |
| 114 |
'PAB' => __('Panamanian Balboa', 'fluent-cart'), |
| 115 |
'PEN' => __('Peruvian Nuevo Sol', 'fluent-cart'), |
| 116 |
'PGK' => __('Papua New Guinean Kina', 'fluent-cart'), |
| 117 |
'PHP' => __('Philippine Peso', 'fluent-cart'), |
| 118 |
'PKR' => __('Pakistani Rupee', 'fluent-cart'), |
| 119 |
'PLN' => __('Polish Złoty', 'fluent-cart'), |
| 120 |
'PYG' => __('Paraguayan Guaraní', 'fluent-cart'), |
| 121 |
'QAR' => __('Qatari Riyal', 'fluent-cart'), |
| 122 |
'RON' => __('Romanian Leu', 'fluent-cart'), |
| 123 |
'RSD' => __('Serbian Dinar', 'fluent-cart'), |
| 124 |
'RUB' => __('Russian Ruble', 'fluent-cart'), |
| 125 |
'RWF' => __('Rwandan Franc', 'fluent-cart'), |
| 126 |
'SAR' => __('Saudi Riyal', 'fluent-cart'), |
| 127 |
'SBD' => __('Solomon Islands Dollar', 'fluent-cart'), |
| 128 |
'SCR' => __('Seychellois Rupee', 'fluent-cart'), |
| 129 |
'SEK' => __('Swedish Krona', 'fluent-cart'), |
| 130 |
'SGD' => __('Singapore Dollar', 'fluent-cart'), |
| 131 |
'SHP' => __('Saint Helenian Pound', 'fluent-cart'), |
| 132 |
'SLL' => __('Sierra Leonean Leone', 'fluent-cart'), |
| 133 |
'SOS' => __('Somali Shilling', 'fluent-cart'), |
| 134 |
'SRD' => __('Surinamese Dollar', 'fluent-cart'), |
| 135 |
'STD' => __('São Tomé and Príncipe Dobra', 'fluent-cart'), |
| 136 |
'SVC' => __('Salvadoran Colón', 'fluent-cart'), |
| 137 |
'SZL' => __('Swazi Lilangeni', 'fluent-cart'), |
| 138 |
'THB' => __('Thai Baht', 'fluent-cart'), |
| 139 |
'TJS' => __('Tajikistani Somoni', 'fluent-cart'), |
| 140 |
'TOP' => __('Tongan Paʻanga', 'fluent-cart'), |
| 141 |
'TRY' => __('Turkish Lira', 'fluent-cart'), |
| 142 |
'TTD' => __('Trinidad and Tobago Dollar', 'fluent-cart'), |
| 143 |
'TWD' => __('New Taiwan Dollar', 'fluent-cart'), |
| 144 |
'TZS' => __('Tanzanian Shilling', 'fluent-cart'), |
| 145 |
'UAH' => __('Ukrainian Hryvnia', 'fluent-cart'), |
| 146 |
'UGX' => __('Ugandan Shilling', 'fluent-cart'), |
| 147 |
'USD' => __('United States Dollar', 'fluent-cart'), |
| 148 |
'UYU' => __('Uruguayan Peso', 'fluent-cart'), |
| 149 |
'UZS' => __('Uzbekistani Som', 'fluent-cart'), |
| 150 |
'VND' => __('Vietnamese Đồng', 'fluent-cart'), |
| 151 |
'VUV' => __('Vanuatu Vatu', 'fluent-cart'), |
| 152 |
'WST' => __('Samoan Tala', 'fluent-cart'), |
| 153 |
'XAF' => __('Central African Cfa Franc', 'fluent-cart'), |
| 154 |
'XCD' => __('East Caribbean Dollar', 'fluent-cart'), |
| 155 |
'XOF' => __('West African Cfa Franc', 'fluent-cart'), |
| 156 |
'XPF' => __('Cfp Franc', 'fluent-cart'), |
| 157 |
'YER' => __('Yemeni Rial', 'fluent-cart'), |
| 158 |
'ZAR' => __('South African Rand', 'fluent-cart'), |
| 159 |
'ZMW' => __('Zambian Kwacha', 'fluent-cart'), |
| 160 |
), []); |
| 161 |
|
| 162 |
if ($code) { |
| 163 |
return isset($currencies[$code]) ? $currencies[$code] : ''; |
| 164 |
} |
| 165 |
|
| 166 |
return $currencies; |
| 167 |
} |
| 168 |
|
| 169 |
/** |
| 170 |
* Get the available locales that Stripe can use |
| 171 |
* |
| 172 |
* @return array |
| 173 |
*/ |
| 174 |
public static function getLocales() |
| 175 |
{ |
| 176 |
return array( |
| 177 |
'' => 'English (en) (default)', |
| 178 |
'auto' => 'Auto-detect locale', |
| 179 |
'zh' => 'Simplified Chinese (zh)', |
| 180 |
'da' => 'Danish (da)', |
| 181 |
'nl' => 'Dutch (nl)', |
| 182 |
'fi' => 'Finnish (fi)', |
| 183 |
'fr' => 'French (fr)', |
| 184 |
'de' => 'German (de)', |
| 185 |
'it' => 'Italian (it)', |
| 186 |
'ja' => 'Japanese (ja)', |
| 187 |
'no' => 'Norwegian (no)', |
| 188 |
'es' => 'Spanish (es)', |
| 189 |
'sv' => 'Swedish (sv)', |
| 190 |
); |
| 191 |
} |
| 192 |
|
| 193 |
public static function getCurrencySigns() |
| 194 |
{ |
| 195 |
return apply_filters('fluent_cart/global_currency_symbols', [ |
| 196 |
'AED' => 'د.إ', |
| 197 |
'AFN' => '؋', |
| 198 |
'ALL' => 'L', |
| 199 |
'AMD' => 'AMD', |
| 200 |
'ANG' => 'ƒ', |
| 201 |
'AOA' => 'Kz', |
| 202 |
'ARS' => '$', |
| 203 |
'AUD' => '$', |
| 204 |
'AWG' => 'Afl.', |
| 205 |
'AZN' => '₼', |
| 206 |
'BAM' => 'KM', |
| 207 |
'BBD' => '$', |
| 208 |
'BDT' => '৳ ', |
| 209 |
'BGN' => 'лв.', |
| 210 |
'BHD' => '.د.ب', |
| 211 |
'BIF' => 'Fr', |
| 212 |
'BMD' => '$', |
| 213 |
'BND' => '$', |
| 214 |
'BOB' => 'Bs.', |
| 215 |
'BRL' => 'R$', |
| 216 |
'BSD' => '$', |
| 217 |
'BTC' => '฿', |
| 218 |
'BTN' => 'Nu.', |
| 219 |
'BWP' => 'P', |
| 220 |
'BYR' => 'Br', |
| 221 |
'BYN' => 'Br', |
| 222 |
'BZD' => '$', |
| 223 |
'CAD' => '$', |
| 224 |
'CDF' => 'Fr', |
| 225 |
'CHF' => 'CHF', |
| 226 |
'CLP' => '$', |
| 227 |
'CNY' => '¥', |
| 228 |
'COP' => '$', |
| 229 |
'CRC' => '₡', |
| 230 |
'CUC' => '$', |
| 231 |
'CUP' => '$', |
| 232 |
'CVE' => '$', |
| 233 |
'CZK' => 'Kč', |
| 234 |
'DJF' => 'Fr', |
| 235 |
'DKK' => 'kr.', |
| 236 |
'DOP' => 'RD$', |
| 237 |
'DZD' => 'د.ج', |
| 238 |
'EGP' => 'EGP', |
| 239 |
'ERN' => 'Nfk', |
| 240 |
'ETB' => 'Br', |
| 241 |
'EUR' => '€', |
| 242 |
'FJD' => '$', |
| 243 |
'FKP' => '£', |
| 244 |
'GBP' => '£', |
| 245 |
'GEL' => '₾', |
| 246 |
'GGP' => '£', |
| 247 |
'GHS' => '₵', |
| 248 |
'GIP' => '£', |
| 249 |
'GMD' => 'D', |
| 250 |
'GNF' => 'Fr', |
| 251 |
'GTQ' => 'Q', |
| 252 |
'GYD' => '$', |
| 253 |
'HKD' => '$', |
| 254 |
'HNL' => 'L', |
| 255 |
'HRK' => 'kn', |
| 256 |
'HTG' => 'G', |
| 257 |
'HUF' => 'Ft', |
| 258 |
'IDR' => 'Rp', |
| 259 |
'ILS' => '₪', |
| 260 |
'IMP' => '£', |
| 261 |
'INR' => '₹', |
| 262 |
'IQD' => 'د.ع', |
| 263 |
'IRR' => '﷼', |
| 264 |
'IRT' => 'تومان', |
| 265 |
'ISK' => 'kr.', |
| 266 |
'JEP' => '£', |
| 267 |
'JMD' => '$', |
| 268 |
'JOD' => 'د.ا', |
| 269 |
'JPY' => '¥', |
| 270 |
'KES' => 'KSh', |
| 271 |
'KGS' => 'сом', |
| 272 |
'KHR' => '៛', |
| 273 |
'KMF' => 'Fr', |
| 274 |
'KPW' => '₩', |
| 275 |
'KRW' => '₩', |
| 276 |
'KWD' => 'د.ك', |
| 277 |
'KYD' => '$', |
| 278 |
'KZT' => '₸', |
| 279 |
'LAK' => '₭', |
| 280 |
'LBP' => 'ل.ل', |
| 281 |
'LKR' => 'රු', |
| 282 |
'LRD' => '$', |
| 283 |
'LSL' => 'L', |
| 284 |
'LYD' => 'د.ل', |
| 285 |
'MAD' => 'د.م.', |
| 286 |
'MDL' => 'MDL', |
| 287 |
'MGA' => 'Ar', |
| 288 |
'MKD' => 'ден', |
| 289 |
'MMK' => 'Ks', |
| 290 |
'MNT' => '₮', |
| 291 |
'MOP' => 'P', |
| 292 |
'MRU' => 'UM', |
| 293 |
'MUR' => '₨', |
| 294 |
'MVR' => '.ރ', |
| 295 |
'MWK' => 'MK', |
| 296 |
'MXN' => '$', |
| 297 |
'MYR' => 'RM', |
| 298 |
'MZN' => 'MT', |
| 299 |
'NAD' => 'N$', |
| 300 |
'NGN' => '₦', |
| 301 |
'NIO' => 'C$', |
| 302 |
'NOK' => 'kr', |
| 303 |
'NPR' => '₨', |
| 304 |
'NZD' => '$', |
| 305 |
'OMR' => 'ر.ع.', |
| 306 |
'PAB' => 'B/.', |
| 307 |
'PEN' => 'S/', |
| 308 |
'PGK' => 'K', |
| 309 |
'PHP' => '₱', |
| 310 |
'PKR' => '₨', |
| 311 |
'PLN' => 'zł', |
| 312 |
'PRB' => 'р.', |
| 313 |
'PYG' => '₲', |
| 314 |
'QAR' => 'ر.ق', |
| 315 |
'RMB' => '¥', |
| 316 |
'RON' => 'lei', |
| 317 |
'RSD' => 'рсд', |
| 318 |
'RUB' => '₽', |
| 319 |
'RWF' => 'Fr', |
| 320 |
'SAR' => 'ر.س', |
| 321 |
'SBD' => '$', |
| 322 |
'SCR' => '₨', |
| 323 |
'SDG' => 'ج.س.', |
| 324 |
'SEK' => 'kr', |
| 325 |
'SGD' => '$', |
| 326 |
'SHP' => '£', |
| 327 |
'SLL' => 'Le', |
| 328 |
'SOS' => 'Sh', |
| 329 |
'SRD' => '$', |
| 330 |
'SSP' => '£', |
| 331 |
'STN' => 'Db', |
| 332 |
'SYP' => 'ل.س', |
| 333 |
'SZL' => 'E', |
| 334 |
'THB' => '฿', |
| 335 |
'TJS' => 'ЅМ', |
| 336 |
'TMT' => 'm', |
| 337 |
'TND' => 'د.ت', |
| 338 |
'TOP' => 'T$', |
| 339 |
'TRY' => '₺', |
| 340 |
'TTD' => '$', |
| 341 |
'TWD' => 'NT$', |
| 342 |
'TZS' => 'Sh', |
| 343 |
'UAH' => '₴', |
| 344 |
'UGX' => 'UGX', |
| 345 |
'USD' => '$', |
| 346 |
'UYU' => '$', |
| 347 |
'UZS' => 'UZS', |
| 348 |
'VEF' => 'Bs F', |
| 349 |
'VES' => 'Bs.', |
| 350 |
'VND' => '₫', |
| 351 |
'VUV' => 'Vt', |
| 352 |
'WST' => 'T', |
| 353 |
'XAF' => 'CFA', |
| 354 |
'XCD' => '$', |
| 355 |
'XOF' => 'CFA', |
| 356 |
'XPF' => 'XPF', |
| 357 |
'YER' => '﷼', |
| 358 |
'ZAR' => 'R', |
| 359 |
'ZMW' => 'ZK', |
| 360 |
], []); |
| 361 |
} |
| 362 |
|
| 363 |
public static function getCurrencySign($currency = 'USD') |
| 364 |
{ |
| 365 |
$currency = strtoupper($currency); |
| 366 |
$symbols = static::getCurrencySigns(); |
| 367 |
return $symbols[$currency] ?? ''; |
| 368 |
} |
| 369 |
|
| 370 |
public static function getCurrencyWithSign($currencies = []) |
| 371 |
{ |
| 372 |
$currencyWithSign = []; |
| 373 |
|
| 374 |
foreach ($currencies as $currency) { |
| 375 |
$currencyWithSign[$currency] = self::getCurrencySign($currency); |
| 376 |
} |
| 377 |
|
| 378 |
return $currencyWithSign; |
| 379 |
} |
| 380 |
|
| 381 |
public static function zeroDecimalCurrencies() |
| 382 |
{ |
| 383 |
return apply_filters('fluent_cart/zero_decimal_currencies', array( |
| 384 |
'BIF' => esc_html__('Burundian Franc', 'fluent-cart'), |
| 385 |
'CLP' => esc_html__('Chilean Peso', 'fluent-cart'), |
| 386 |
'DJF' => esc_html__('Djiboutian Franc', 'fluent-cart'), |
| 387 |
'GNF' => esc_html__('Guinean Franc', 'fluent-cart'), |
| 388 |
'JPY' => esc_html__('Japanese Yen', 'fluent-cart'), |
| 389 |
'KMF' => esc_html__('Comorian Franc', 'fluent-cart'), |
| 390 |
'KRW' => esc_html__('South Korean Won', 'fluent-cart'), |
| 391 |
'MGA' => esc_html__('Malagasy Ariary', 'fluent-cart'), |
| 392 |
'PYG' => esc_html__('Paraguayan Guaraní', 'fluent-cart'), |
| 393 |
'RWF' => esc_html__('Rwandan Franc', 'fluent-cart'), |
| 394 |
'VND' => esc_html__('Vietnamese Dong', 'fluent-cart'), |
| 395 |
'VUV' => esc_html__('Vanuatu Vatu', 'fluent-cart'), |
| 396 |
'XAF' => esc_html__('Central African Cfa Franc', 'fluent-cart'), |
| 397 |
'XOF' => esc_html__('West African Cfa Franc', 'fluent-cart'), |
| 398 |
'XPF' => esc_html__('Cfp Franc', 'fluent-cart'), |
| 399 |
'UGX' => esc_html__('Ugandan Shilling', 'fluent-cart'), |
| 400 |
), []); |
| 401 |
} |
| 402 |
|
| 403 |
public static function isZeroDecimal($currencyCode): bool |
| 404 |
{ |
| 405 |
$currencyCode = strtoupper($currencyCode); |
| 406 |
$zeroDecimals = self::zeroDecimalCurrencies(); |
| 407 |
return isset($zeroDecimals[$currencyCode]); |
| 408 |
} |
| 409 |
|
| 410 |
public static function updateCurrencyArray($oldCurrencies = [], $amount = 0, $currency = ''): array |
| 411 |
{ |
| 412 |
if (!Arr::exists($oldCurrencies, $currency)) { |
| 413 |
$oldCurrencies[$currency] = [ |
| 414 |
'currency' => $currency, |
| 415 |
'total' => 0, |
| 416 |
'count' => 0, |
| 417 |
'sign' => '$' |
| 418 |
]; |
| 419 |
} |
| 420 |
|
| 421 |
$oldCurrencies[$currency]['total'] += $amount; |
| 422 |
$oldCurrencies[$currency]['count']++; |
| 423 |
$oldCurrencies[$currency]['sign'] = static::getCurrencySign($currency); |
| 424 |
|
| 425 |
return $oldCurrencies; |
| 426 |
} |
| 427 |
|
| 428 |
public static function centsToDecimal($cents, $currency = null) |
| 429 |
{ |
| 430 |
|
| 431 |
if (!$currency) { |
| 432 |
$currency = CurrencySettings::get('currency'); |
| 433 |
} |
| 434 |
|
| 435 |
if (self::isZeroDecimal($currency)) { |
| 436 |
return $cents; |
| 437 |
} |
| 438 |
|
| 439 |
return number_format($cents / 100, 2, '.', ''); |
| 440 |
} |
| 441 |
} |
| 442 |
|