Create New Item
Item Type
File
Folder
Item Name
Search file in folder and subfolders...
Are you sure want to rename?
File Manager
/
wp-content
/
plugins
/
woocommerce-multilingual
/
classes
/
Multicurrency
/
Resolver
:
HelperByLocation.php
Advanced Search
Upload
New Item
Settings
Back
Back Up
Advanced Editor
Save
<?php namespace WCML\MultiCurrency\Resolver; use WCML\MultiCurrency\Geolocation; use WCML\MultiCurrency\Settings; use WPML\FP\Fns; class HelperByLocation { /** @var null|callable $getCurrency */ private static $getCurrency; /** * @return string|null */ public static function getCurrencyByUserCountry() { if ( ! self::$getCurrency ) { self::$getCurrency = Fns::memorize( function() { $clientCountry = Geolocation::getUserCountry(); $currency = Geolocation::getOfficialCurrencyCodeByCountry( $clientCountry ); if ( ! Settings::isValidCurrencyByCountry( $currency, $clientCountry ) ) { $currency = Settings::getFirstAvailableCurrencyByCountry( $clientCountry ); } return $currency ?: null; } ); } return call_user_func( self::$getCurrency ); } }