diff --git a/copy_this/modules/d3/d3geoip/components/d3cmp_geoip.php b/copy_this/modules/d3/d3geoip/components/d3cmp_geoip.php index af86929..6cbc9d8 100644 --- a/copy_this/modules/d3/d3geoip/components/d3cmp_geoip.php +++ b/copy_this/modules/d3/d3geoip/components/d3cmp_geoip.php @@ -41,6 +41,23 @@ class d3cmp_geoip extends oxView $oLocation = oxNew('d3geoip'); $oLocation->setCountryCurrency(); $oLocation->setCountryLanguage(); + + if (!isset($oBasket)) { + $oBasket = $this->getSession()->getBasket(); + } + + // call component again, if curr is registered before we changed it + // reason: own component can added after default components only + if ($oLocation->hasNotSetCurrency($oBasket->getBasketCurrency())) { + /** @var oxUBase $oActView */ + $oActView = oxRegistry::getConfig()->getActiveView(); + $aComponents = $oActView->getComponents(); + + /** @var oxcmp_cur $oCurCmp */ + $oCurCmp = $aComponents['oxcmp_cur']; + $oCurCmp->init(); + } + // language isn't registered, we don't need an additional check } parent::init(); diff --git a/copy_this/modules/d3/d3geoip/controllers/admin/d3_country_geoip.php b/copy_this/modules/d3/d3geoip/controllers/admin/d3_country_geoip.php index 1f00486..a44c328 100644 --- a/copy_this/modules/d3/d3geoip/controllers/admin/d3_country_geoip.php +++ b/copy_this/modules/d3/d3geoip/controllers/admin/d3_country_geoip.php @@ -160,7 +160,10 @@ class d3_country_geoip extends oxAdminView */ public function getCurList() { - if ($this->getModCfgValue('blChangeShop') && $this->oCountry->getFieldData('d3geoipshop')) { + if ($this->getModCfgValue('blChangeShop') + && $this->oCountry->getFieldData('d3geoipshop') + && $this->oCountry->getFieldData('d3geoipshop') > 0 // -1 is user choice + ) { $sShopId = $this->oCountry->getFieldData('d3geoipshop'); } else { $sShopId = oxRegistry::getConfig()->getActiveView()->getViewConfig()->getActiveShopId(); @@ -186,9 +189,9 @@ class d3_country_geoip extends oxAdminView if ($sCurrencies) { foreach (unserialize($sCurrencies) as $sKey => $sValue) { $aFields = explode('@', $sValue); - $aCurrencies[$sKey]->id = $sKey; - $aCurrencies[$sKey]->name = $aFields[0]; - $aCurrencies[$sKey]->sign = $aFields[4]; + $aCurrencies[$sKey]->id = trim($sKey); + $aCurrencies[$sKey]->name = trim($aFields[0]); + $aCurrencies[$sKey]->sign = trim($aFields[4]); } } @@ -201,7 +204,10 @@ class d3_country_geoip extends oxAdminView */ public function getLangList() { - if ($this->getModCfgValue('blChangeShop') && $this->oCountry->getFieldData('d3geoipshop')) { + if ($this->getModCfgValue('blChangeShop') + && $this->oCountry->getFieldData('d3geoipshop') + && $this->oCountry->getFieldData('d3geoipshop') > 0 // -1 is user choice + ) { $sShopId = $this->oCountry->getFieldData('d3geoipshop'); } else { $sShopId = oxRegistry::getConfig()->getActiveView()->getViewConfig()->getActiveShopId(); @@ -239,12 +245,6 @@ class d3_country_geoip extends oxAdminView $oLang->sort = $aLangParams[$key]['sort']; } - if (isset($iLanguage) && $oLang->id == $iLanguage) { - $oLang->selected = 1; - } else { - $oLang->selected = 0; - } - if ($oLang->active) { $aLanguages[$oLang->id] = $oLang; } diff --git a/copy_this/modules/d3/d3geoip/models/d3geoip.php b/copy_this/modules/d3/d3geoip/models/d3geoip.php index a5c8a89..2bd6a8b 100644 --- a/copy_this/modules/d3/d3geoip/models/d3geoip.php +++ b/copy_this/modules/d3/d3geoip/models/d3geoip.php @@ -307,6 +307,22 @@ class d3GeoIP extends oxbase stopProfile(__METHOD__); } + /** + * @param $oCurr + * @return bool + */ + public function hasNotSetCurrency($oCurr) + { + $oCountry = $this->getUserLocationCountryObject(); + if ($oCountry->getFieldData('d3geoipcur') > 0 + && $oCurr->id != $oCountry->getFieldData('d3geoipcur') + ) { + return true; + } + + return false; + } + /** * check module active state and perform switching to user country specific shop (EE only) *