avoid unset currency on first call,

fix unselectable currencies and languages, if country shop is set to user choice
This commit is contained in:
Daniel Seifert 2016-02-25 16:47:32 +00:00
parent ce8cff7cd1
commit c6264dfcc9
3 changed files with 44 additions and 11 deletions

View File

@ -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();

View File

@ -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;
}

View File

@ -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)
*