| 1 |
<?php |
| 2 |
|
| 3 |
namespace StoreEngine\Utils\traits; |
| 4 |
|
| 5 |
use StoreEngine\Utils\Formatting; |
| 6 |
|
| 7 |
trait Currency { |
| 8 |
|
| 9 |
private static array $currency_symbols = [ |
| 10 |
'AED' => 'د.إ', |
| 11 |
'AFN' => '؋', |
| 12 |
'ALL' => 'L', |
| 13 |
'AMD' => 'AMD', |
| 14 |
'ANG' => 'ƒ', |
| 15 |
'AOA' => 'Kz', |
| 16 |
'ARS' => '$', |
| 17 |
'AUD' => '$', |
| 18 |
'AWG' => 'Afl.', |
| 19 |
'AZN' => '₼', |
| 20 |
'BAM' => 'KM', |
| 21 |
'BBD' => '$', |
| 22 |
'BDT' => '৳ ', |
| 23 |
'BGN' => 'лв.', |
| 24 |
'BHD' => '.د.ب', |
| 25 |
'BIF' => 'Fr', |
| 26 |
'BMD' => '$', |
| 27 |
'BND' => '$', |
| 28 |
'BOB' => 'Bs.', |
| 29 |
'BRL' => 'R$', |
| 30 |
'BSD' => '$', |
| 31 |
'BTC' => '฿', |
| 32 |
'BTN' => 'Nu.', |
| 33 |
'BWP' => 'P', |
| 34 |
'BYR' => 'Br', |
| 35 |
'BYN' => 'Br', |
| 36 |
'BZD' => '$', |
| 37 |
'CAD' => '$', |
| 38 |
'CDF' => 'Fr', |
| 39 |
'CHF' => 'CHF', |
| 40 |
'CLP' => '$', |
| 41 |
'CNY' => '¥', |
| 42 |
'COP' => '$', |
| 43 |
'CRC' => '₡', |
| 44 |
'CUC' => '$', |
| 45 |
'CUP' => '$', |
| 46 |
'CVE' => '$', |
| 47 |
'CZK' => 'Kč', |
| 48 |
'DJF' => 'Fr', |
| 49 |
'DKK' => 'kr.', |
| 50 |
'DOP' => 'RD$', |
| 51 |
'DZD' => 'د.ج', |
| 52 |
'EGP' => 'EGP', |
| 53 |
'ERN' => 'Nfk', |
| 54 |
'ETB' => 'Br', |
| 55 |
'EUR' => '€', |
| 56 |
'FJD' => '$', |
| 57 |
'FKP' => '£', |
| 58 |
'GBP' => '£', |
| 59 |
'GEL' => '₾', |
| 60 |
'GGP' => '£', |
| 61 |
'GHS' => '₵', |
| 62 |
'GIP' => '£', |
| 63 |
'GMD' => 'D', |
| 64 |
'GNF' => 'Fr', |
| 65 |
'GTQ' => 'Q', |
| 66 |
'GYD' => '$', |
| 67 |
'HKD' => '$', |
| 68 |
'HNL' => 'L', |
| 69 |
'HRK' => 'kn', |
| 70 |
'HTG' => 'G', |
| 71 |
'HUF' => 'Ft', |
| 72 |
'IDR' => 'Rp', |
| 73 |
'ILS' => '₪', |
| 74 |
'IMP' => '£', |
| 75 |
'INR' => '₹', |
| 76 |
'IQD' => 'د.ع', |
| 77 |
'IRR' => '﷼', |
| 78 |
'IRT' => 'تومان', |
| 79 |
'ISK' => 'kr.', |
| 80 |
'JEP' => '£', |
| 81 |
'JMD' => '$', |
| 82 |
'JOD' => 'د.ا', |
| 83 |
'JPY' => '¥', |
| 84 |
'KES' => 'KSh', |
| 85 |
'KGS' => 'сом', |
| 86 |
'KHR' => '៛', |
| 87 |
'KMF' => 'Fr', |
| 88 |
'KPW' => '₩', |
| 89 |
'KRW' => '₩', |
| 90 |
'KWD' => 'د.ك', |
| 91 |
'KYD' => '$', |
| 92 |
'KZT' => '₸', |
| 93 |
'LAK' => '₭', |
| 94 |
'LBP' => 'ل.ل', |
| 95 |
'LKR' => 'රු', |
| 96 |
'LRD' => '$', |
| 97 |
'LSL' => 'L', |
| 98 |
'LYD' => 'د.ل', |
| 99 |
'MAD' => 'د.م.', |
| 100 |
'MDL' => 'MDL', |
| 101 |
'MGA' => 'Ar', |
| 102 |
'MKD' => 'ден', |
| 103 |
'MMK' => 'Ks', |
| 104 |
'MNT' => '₮', |
| 105 |
'MOP' => 'P', |
| 106 |
'MRU' => 'UM', |
| 107 |
'MUR' => '₨', |
| 108 |
'MVR' => '.ރ', |
| 109 |
'MWK' => 'MK', |
| 110 |
'MXN' => '$', |
| 111 |
'MYR' => 'RM', |
| 112 |
'MZN' => 'MT', |
| 113 |
'NAD' => 'N$', |
| 114 |
'NGN' => '₦', |
| 115 |
'NIO' => 'C$', |
| 116 |
'NOK' => 'kr', |
| 117 |
'NPR' => '₨', |
| 118 |
'NZD' => '$', |
| 119 |
'OMR' => 'ر.ع.', |
| 120 |
'PAB' => 'B/.', |
| 121 |
'PEN' => 'S/', |
| 122 |
'PGK' => 'K', |
| 123 |
'PHP' => '₱', |
| 124 |
'PKR' => '₨', |
| 125 |
'PLN' => 'zł', |
| 126 |
'PRB' => 'р.', |
| 127 |
'PYG' => '₲', |
| 128 |
'QAR' => 'ر.ق', |
| 129 |
'RMB' => '¥', |
| 130 |
'RON' => 'lei', |
| 131 |
'RSD' => 'рсд', |
| 132 |
'RUB' => '₽', |
| 133 |
'RWF' => 'Fr', |
| 134 |
'SAR' => 'ر.س', |
| 135 |
'SBD' => '$', |
| 136 |
'SCR' => '₨', |
| 137 |
'SDG' => 'ج.س.', |
| 138 |
'SEK' => 'kr', |
| 139 |
'SGD' => '$', |
| 140 |
'SHP' => '£', |
| 141 |
'SLL' => 'Le', |
| 142 |
'SOS' => 'Sh', |
| 143 |
'SRD' => '$', |
| 144 |
'SSP' => '£', |
| 145 |
'STN' => 'Db', |
| 146 |
'SYP' => 'ل.س', |
| 147 |
'SZL' => 'E', |
| 148 |
'THB' => '฿', |
| 149 |
'TJS' => 'ЅМ', |
| 150 |
'TMT' => 'm', |
| 151 |
'TND' => 'د.ت', |
| 152 |
'TOP' => 'T$', |
| 153 |
'TRY' => '₺', |
| 154 |
'TTD' => '$', |
| 155 |
'TWD' => 'NT$', |
| 156 |
'TZS' => 'Sh', |
| 157 |
'UAH' => '₴', |
| 158 |
'UGX' => 'UGX', |
| 159 |
'USD' => '$', |
| 160 |
'UYU' => '$', |
| 161 |
'UZS' => 'UZS', |
| 162 |
'VEF' => 'Bs F', |
| 163 |
'VES' => 'Bs.', |
| 164 |
'VND' => '₫', |
| 165 |
'VUV' => 'Vt', |
| 166 |
'WST' => 'T', |
| 167 |
'XAF' => 'CFA', |
| 168 |
'XCD' => '$', |
| 169 |
'XOF' => 'CFA', |
| 170 |
'XPF' => 'XPF', |
| 171 |
'YER' => '﷼', |
| 172 |
'ZAR' => 'R', |
| 173 |
'ZMW' => 'ZK', |
| 174 |
]; |
| 175 |
|
| 176 |
public static function get_currency_symbols(): array { |
| 177 |
return apply_filters( 'storeengine/currency_symbols', self::$currency_symbols ); |
| 178 |
} |
| 179 |
|
| 180 |
/** |
| 181 |
* Get Currency symbol. |
| 182 |
* |
| 183 |
* Currency symbols and names should follow the Unicode CLDR recommendation (https://cldr.unicode.org/translation/currency-names-and-symbols) |
| 184 |
* |
| 185 |
* @param string $currency Currency. (default: ''). |
| 186 |
* |
| 187 |
* @return string |
| 188 |
*/ |
| 189 |
public static function get_currency_symbol( string $currency = '' ): string { |
| 190 |
if ( ! $currency ) { |
| 191 |
$currency = Formatting::get_currency(); |
| 192 |
} |
| 193 |
|
| 194 |
$symbols = self::get_currency_symbols(); |
| 195 |
$symbol = $currency ? ( $symbols[ $currency ] ?? '' ) : ''; |
| 196 |
|
| 197 |
return apply_filters( 'storeengine/currency_symbol', $symbol, $currency ); |
| 198 |
} |
| 199 |
|
| 200 |
/** |
| 201 |
* Get full list of currency codes. |
| 202 |
* |
| 203 |
* Currency symbols and names should follow the Unicode CLDR recommendation (https://cldr.unicode.org/translation/currency-names-and-symbols) |
| 204 |
* |
| 205 |
* @return array |
| 206 |
*/ |
| 207 |
public static function get_currencies(): array { |
| 208 |
static $currencies; |
| 209 |
|
| 210 |
if ( ! isset( $currencies ) ) { |
| 211 |
$currencies = array_unique( apply_filters( 'storeengine/currencies', [ |
| 212 |
'AED' => __( 'United Arab Emirates dirham', 'storeengine' ), |
| 213 |
'AFN' => __( 'Afghan afghani', 'storeengine' ), |
| 214 |
'ALL' => __( 'Albanian lek', 'storeengine' ), |
| 215 |
'AMD' => __( 'Armenian dram', 'storeengine' ), |
| 216 |
'ANG' => __( 'Netherlands Antillean guilder', 'storeengine' ), |
| 217 |
'AOA' => __( 'Angolan kwanza', 'storeengine' ), |
| 218 |
'ARS' => __( 'Argentine peso', 'storeengine' ), |
| 219 |
'AUD' => __( 'Australian dollar', 'storeengine' ), |
| 220 |
'AWG' => __( 'Aruban florin', 'storeengine' ), |
| 221 |
'AZN' => __( 'Azerbaijani manat', 'storeengine' ), |
| 222 |
'BAM' => __( 'Bosnia and Herzegovina convertible mark', 'storeengine' ), |
| 223 |
'BBD' => __( 'Barbadian dollar', 'storeengine' ), |
| 224 |
'BDT' => __( 'Bangladeshi taka', 'storeengine' ), |
| 225 |
'BGN' => __( 'Bulgarian lev', 'storeengine' ), |
| 226 |
'BHD' => __( 'Bahraini dinar', 'storeengine' ), |
| 227 |
'BIF' => __( 'Burundian franc', 'storeengine' ), |
| 228 |
'BMD' => __( 'Bermudian dollar', 'storeengine' ), |
| 229 |
'BND' => __( 'Brunei dollar', 'storeengine' ), |
| 230 |
'BOB' => __( 'Bolivian boliviano', 'storeengine' ), |
| 231 |
'BRL' => __( 'Brazilian real', 'storeengine' ), |
| 232 |
'BSD' => __( 'Bahamian dollar', 'storeengine' ), |
| 233 |
'BTC' => __( 'Bitcoin', 'storeengine' ), |
| 234 |
'BTN' => __( 'Bhutanese ngultrum', 'storeengine' ), |
| 235 |
'BWP' => __( 'Botswana pula', 'storeengine' ), |
| 236 |
'BYR' => __( 'Belarusian ruble (old)', 'storeengine' ), |
| 237 |
'BYN' => __( 'Belarusian ruble', 'storeengine' ), |
| 238 |
'BZD' => __( 'Belize dollar', 'storeengine' ), |
| 239 |
'CAD' => __( 'Canadian dollar', 'storeengine' ), |
| 240 |
'CDF' => __( 'Congolese franc', 'storeengine' ), |
| 241 |
'CHF' => __( 'Swiss franc', 'storeengine' ), |
| 242 |
'CLP' => __( 'Chilean peso', 'storeengine' ), |
| 243 |
'CNY' => __( 'Chinese yuan', 'storeengine' ), |
| 244 |
'COP' => __( 'Colombian peso', 'storeengine' ), |
| 245 |
'CRC' => __( 'Costa Rican colón', 'storeengine' ), |
| 246 |
'CUC' => __( 'Cuban convertible peso', 'storeengine' ), |
| 247 |
'CUP' => __( 'Cuban peso', 'storeengine' ), |
| 248 |
'CVE' => __( 'Cape Verdean escudo', 'storeengine' ), |
| 249 |
'CZK' => __( 'Czech koruna', 'storeengine' ), |
| 250 |
'DJF' => __( 'Djiboutian franc', 'storeengine' ), |
| 251 |
'DKK' => __( 'Danish krone', 'storeengine' ), |
| 252 |
'DOP' => __( 'Dominican peso', 'storeengine' ), |
| 253 |
'DZD' => __( 'Algerian dinar', 'storeengine' ), |
| 254 |
'EGP' => __( 'Egyptian pound', 'storeengine' ), |
| 255 |
'ERN' => __( 'Eritrean nakfa', 'storeengine' ), |
| 256 |
'ETB' => __( 'Ethiopian birr', 'storeengine' ), |
| 257 |
'EUR' => __( 'Euro', 'storeengine' ), |
| 258 |
'FJD' => __( 'Fijian dollar', 'storeengine' ), |
| 259 |
'FKP' => __( 'Falkland Islands pound', 'storeengine' ), |
| 260 |
'GBP' => __( 'Pound sterling', 'storeengine' ), |
| 261 |
'GEL' => __( 'Georgian lari', 'storeengine' ), |
| 262 |
'GGP' => __( 'Guernsey pound', 'storeengine' ), |
| 263 |
'GHS' => __( 'Ghana cedi', 'storeengine' ), |
| 264 |
'GIP' => __( 'Gibraltar pound', 'storeengine' ), |
| 265 |
'GMD' => __( 'Gambian dalasi', 'storeengine' ), |
| 266 |
'GNF' => __( 'Guinean franc', 'storeengine' ), |
| 267 |
'GTQ' => __( 'Guatemalan quetzal', 'storeengine' ), |
| 268 |
'GYD' => __( 'Guyanese dollar', 'storeengine' ), |
| 269 |
'HKD' => __( 'Hong Kong dollar', 'storeengine' ), |
| 270 |
'HNL' => __( 'Honduran lempira', 'storeengine' ), |
| 271 |
'HRK' => __( 'Croatian kuna', 'storeengine' ), |
| 272 |
'HTG' => __( 'Haitian gourde', 'storeengine' ), |
| 273 |
'HUF' => __( 'Hungarian forint', 'storeengine' ), |
| 274 |
'IDR' => __( 'Indonesian rupiah', 'storeengine' ), |
| 275 |
'ILS' => __( 'Israeli new shekel', 'storeengine' ), |
| 276 |
'IMP' => __( 'Manx pound', 'storeengine' ), |
| 277 |
'INR' => __( 'Indian rupee', 'storeengine' ), |
| 278 |
'IQD' => __( 'Iraqi dinar', 'storeengine' ), |
| 279 |
'IRR' => __( 'Iranian rial', 'storeengine' ), |
| 280 |
'IRT' => __( 'Iranian toman', 'storeengine' ), |
| 281 |
'ISK' => __( 'Icelandic króna', 'storeengine' ), |
| 282 |
'JEP' => __( 'Jersey pound', 'storeengine' ), |
| 283 |
'JMD' => __( 'Jamaican dollar', 'storeengine' ), |
| 284 |
'JOD' => __( 'Jordanian dinar', 'storeengine' ), |
| 285 |
'JPY' => __( 'Japanese yen', 'storeengine' ), |
| 286 |
'KES' => __( 'Kenyan shilling', 'storeengine' ), |
| 287 |
'KGS' => __( 'Kyrgyzstani som', 'storeengine' ), |
| 288 |
'KHR' => __( 'Cambodian riel', 'storeengine' ), |
| 289 |
'KMF' => __( 'Comorian franc', 'storeengine' ), |
| 290 |
'KPW' => __( 'North Korean won', 'storeengine' ), |
| 291 |
'KRW' => __( 'South Korean won', 'storeengine' ), |
| 292 |
'KWD' => __( 'Kuwaiti dinar', 'storeengine' ), |
| 293 |
'KYD' => __( 'Cayman Islands dollar', 'storeengine' ), |
| 294 |
'KZT' => __( 'Kazakhstani tenge', 'storeengine' ), |
| 295 |
'LAK' => __( 'Lao kip', 'storeengine' ), |
| 296 |
'LBP' => __( 'Lebanese pound', 'storeengine' ), |
| 297 |
'LKR' => __( 'Sri Lankan rupee', 'storeengine' ), |
| 298 |
'LRD' => __( 'Liberian dollar', 'storeengine' ), |
| 299 |
'LSL' => __( 'Lesotho loti', 'storeengine' ), |
| 300 |
'LYD' => __( 'Libyan dinar', 'storeengine' ), |
| 301 |
'MAD' => __( 'Moroccan dirham', 'storeengine' ), |
| 302 |
'MDL' => __( 'Moldovan leu', 'storeengine' ), |
| 303 |
'MGA' => __( 'Malagasy ariary', 'storeengine' ), |
| 304 |
'MKD' => __( 'Macedonian denar', 'storeengine' ), |
| 305 |
'MMK' => __( 'Burmese kyat', 'storeengine' ), |
| 306 |
'MNT' => __( 'Mongolian tögrög', 'storeengine' ), |
| 307 |
'MOP' => __( 'Macanese pataca', 'storeengine' ), |
| 308 |
'MRU' => __( 'Mauritanian ouguiya', 'storeengine' ), |
| 309 |
'MUR' => __( 'Mauritian rupee', 'storeengine' ), |
| 310 |
'MVR' => __( 'Maldivian rufiyaa', 'storeengine' ), |
| 311 |
'MWK' => __( 'Malawian kwacha', 'storeengine' ), |
| 312 |
'MXN' => __( 'Mexican peso', 'storeengine' ), |
| 313 |
'MYR' => __( 'Malaysian ringgit', 'storeengine' ), |
| 314 |
'MZN' => __( 'Mozambican metical', 'storeengine' ), |
| 315 |
'NAD' => __( 'Namibian dollar', 'storeengine' ), |
| 316 |
'NGN' => __( 'Nigerian naira', 'storeengine' ), |
| 317 |
'NIO' => __( 'Nicaraguan córdoba', 'storeengine' ), |
| 318 |
'NOK' => __( 'Norwegian krone', 'storeengine' ), |
| 319 |
'NPR' => __( 'Nepalese rupee', 'storeengine' ), |
| 320 |
'NZD' => __( 'New Zealand dollar', 'storeengine' ), |
| 321 |
'OMR' => __( 'Omani rial', 'storeengine' ), |
| 322 |
'PAB' => __( 'Panamanian balboa', 'storeengine' ), |
| 323 |
'PEN' => __( 'Sol', 'storeengine' ), |
| 324 |
'PGK' => __( 'Papua New Guinean kina', 'storeengine' ), |
| 325 |
'PHP' => __( 'Philippine peso', 'storeengine' ), |
| 326 |
'PKR' => __( 'Pakistani rupee', 'storeengine' ), |
| 327 |
'PLN' => __( 'Polish złoty', 'storeengine' ), |
| 328 |
'PRB' => __( 'Transnistrian ruble', 'storeengine' ), |
| 329 |
'PYG' => __( 'Paraguayan guaraní', 'storeengine' ), |
| 330 |
'QAR' => __( 'Qatari riyal', 'storeengine' ), |
| 331 |
'RON' => __( 'Romanian leu', 'storeengine' ), |
| 332 |
'RSD' => __( 'Serbian dinar', 'storeengine' ), |
| 333 |
'RUB' => __( 'Russian ruble', 'storeengine' ), |
| 334 |
'RWF' => __( 'Rwandan franc', 'storeengine' ), |
| 335 |
'SAR' => __( 'Saudi riyal', 'storeengine' ), |
| 336 |
'SBD' => __( 'Solomon Islands dollar', 'storeengine' ), |
| 337 |
'SCR' => __( 'Seychellois rupee', 'storeengine' ), |
| 338 |
'SDG' => __( 'Sudanese pound', 'storeengine' ), |
| 339 |
'SEK' => __( 'Swedish krona', 'storeengine' ), |
| 340 |
'SGD' => __( 'Singapore dollar', 'storeengine' ), |
| 341 |
'SHP' => __( 'Saint Helena pound', 'storeengine' ), |
| 342 |
'SLL' => __( 'Sierra Leonean leone', 'storeengine' ), |
| 343 |
'SOS' => __( 'Somali shilling', 'storeengine' ), |
| 344 |
'SRD' => __( 'Surinamese dollar', 'storeengine' ), |
| 345 |
'SSP' => __( 'South Sudanese pound', 'storeengine' ), |
| 346 |
'STN' => __( 'São Tomé and Príncipe dobra', 'storeengine' ), |
| 347 |
'SYP' => __( 'Syrian pound', 'storeengine' ), |
| 348 |
'SZL' => __( 'Swazi lilangeni', 'storeengine' ), |
| 349 |
'THB' => __( 'Thai baht', 'storeengine' ), |
| 350 |
'TJS' => __( 'Tajikistani somoni', 'storeengine' ), |
| 351 |
'TMT' => __( 'Turkmenistan manat', 'storeengine' ), |
| 352 |
'TND' => __( 'Tunisian dinar', 'storeengine' ), |
| 353 |
'TOP' => __( 'Tongan paʻanga', 'storeengine' ), |
| 354 |
'TRY' => __( 'Turkish lira', 'storeengine' ), |
| 355 |
'TTD' => __( 'Trinidad and Tobago dollar', 'storeengine' ), |
| 356 |
'TWD' => __( 'New Taiwan dollar', 'storeengine' ), |
| 357 |
'TZS' => __( 'Tanzanian shilling', 'storeengine' ), |
| 358 |
'UAH' => __( 'Ukrainian hryvnia', 'storeengine' ), |
| 359 |
'UGX' => __( 'Ugandan shilling', 'storeengine' ), |
| 360 |
'USD' => __( 'United States (US) dollar', 'storeengine' ), |
| 361 |
'UYU' => __( 'Uruguayan peso', 'storeengine' ), |
| 362 |
'UZS' => __( 'Uzbekistani som', 'storeengine' ), |
| 363 |
'VEF' => __( 'Venezuelan bolívar (2008–2018)', 'storeengine' ), |
| 364 |
'VES' => __( 'Venezuelan bolívar', 'storeengine' ), |
| 365 |
'VND' => __( 'Vietnamese đồng', 'storeengine' ), |
| 366 |
'VUV' => __( 'Vanuatu vatu', 'storeengine' ), |
| 367 |
'WST' => __( 'Samoan tālā', 'storeengine' ), |
| 368 |
'XAF' => __( 'Central African CFA franc', 'storeengine' ), |
| 369 |
'XCD' => __( 'East Caribbean dollar', 'storeengine' ), |
| 370 |
'XOF' => __( 'West African CFA franc', 'storeengine' ), |
| 371 |
'XPF' => __( 'CFP franc', 'storeengine' ), |
| 372 |
'YER' => __( 'Yemeni rial', 'storeengine' ), |
| 373 |
'ZAR' => __( 'South African rand', 'storeengine' ), |
| 374 |
'ZMW' => __( 'Zambian kwacha', 'storeengine' ), |
| 375 |
] ) ); |
| 376 |
} |
| 377 |
|
| 378 |
return $currencies; |
| 379 |
} |
| 380 |
|
| 381 |
/** |
| 382 |
* @return array |
| 383 |
* @deprecated Use individual utility methods. |
| 384 |
*/ |
| 385 |
public static function get_currency_options(): array { |
| 386 |
return apply_filters( 'storeengine/currency_options', [ |
| 387 |
'currency' => Formatting::get_currency(), |
| 388 |
'currency_position' => Formatting::get_currency_position(), |
| 389 |
'currency_thousand_separator' => Formatting::get_price_thousand_separator(), |
| 390 |
'currency_decimal_separator' => Formatting::get_price_decimal_separator(), |
| 391 |
'currency_decimal_limit' => Formatting::get_price_decimals(), |
| 392 |
'rounding_precision' => Formatting::get_rounding_precision(), |
| 393 |
'currency_symbol' => self::get_currency_symbol( Formatting::get_currency() ), |
| 394 |
] ); |
| 395 |
} |
| 396 |
|
| 397 |
/** |
| 398 |
* Get Base Currency Code. |
| 399 |
* |
| 400 |
* @return string |
| 401 |
* |
| 402 |
* @deprecated |
| 403 |
*/ |
| 404 |
public static function get_currency(): string { |
| 405 |
return Formatting::get_currency(); |
| 406 |
} |
| 407 |
|
| 408 |
/** |
| 409 |
* @param string|float|int $price |
| 410 |
* @param array $args |
| 411 |
* |
| 412 |
* @return string |
| 413 |
* @deprecated |
| 414 |
* @use \StoreEngine\Utils\Formatting::price() |
| 415 |
* |
| 416 |
*/ |
| 417 |
public static function currency_format( $price, array $args = [] ): string { |
| 418 |
if ( ! isset( $price ) ) { |
| 419 |
return ''; |
| 420 |
} |
| 421 |
$currency_options = self::get_currency_options(); |
| 422 |
$currency_symbol = $currency_options['currency_symbol']; |
| 423 |
$currency_position = $currency_options['currency_position']; |
| 424 |
$price = number_format( |
| 425 |
(float) $price, |
| 426 |
$currency_options['currency_decimal_limit'], |
| 427 |
$currency_options['currency_decimal_separator'], |
| 428 |
$currency_options['currency_thousand_separator'] |
| 429 |
); |
| 430 |
|
| 431 |
return 'left' === $currency_position ? $currency_symbol . $price : $price . $currency_symbol; |
| 432 |
} |
| 433 |
} |
| 434 |
|