Geolocation.php
1 week ago
GeolocationBackendHooks.php
4 years ago
GeolocationFrontendHooks.php
4 years ago
GeolocationFrontendHooks.php
21 lines
| 1 | <?php |
| 2 | |
| 3 | namespace WCML\MultiCurrency; |
| 4 | |
| 5 | use WCML\StandAlone\IStandAloneAction; |
| 6 | |
| 7 | class GeolocationFrontendHooks implements \IWPML_Frontend_Action, IStandAloneAction { |
| 8 | |
| 9 | const KEY_CLIENT_COUNTRY = 'wcml_client_country'; |
| 10 | |
| 11 | public function add_hooks() { |
| 12 | if ( Geolocation::isUsed() ) { |
| 13 | add_action( 'init', [ self::class, 'storeUserCountry' ] ); |
| 14 | } |
| 15 | } |
| 16 | |
| 17 | public static function storeUserCountry() { |
| 18 | wcml_user_store_set( self::KEY_CLIENT_COUNTRY, Geolocation::getUserCountry() ); |
| 19 | } |
| 20 | } |
| 21 |