avoid unset currency on first call,
fix unselectable currencies and languages, if country shop is set to user choice
This commit is contained in:
parent
ce8cff7cd1
commit
c6264dfcc9
@ -41,6 +41,23 @@ class d3cmp_geoip extends oxView
|
|||||||
$oLocation = oxNew('d3geoip');
|
$oLocation = oxNew('d3geoip');
|
||||||
$oLocation->setCountryCurrency();
|
$oLocation->setCountryCurrency();
|
||||||
$oLocation->setCountryLanguage();
|
$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();
|
parent::init();
|
||||||
|
@ -160,7 +160,10 @@ class d3_country_geoip extends oxAdminView
|
|||||||
*/
|
*/
|
||||||
public function getCurList()
|
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');
|
$sShopId = $this->oCountry->getFieldData('d3geoipshop');
|
||||||
} else {
|
} else {
|
||||||
$sShopId = oxRegistry::getConfig()->getActiveView()->getViewConfig()->getActiveShopId();
|
$sShopId = oxRegistry::getConfig()->getActiveView()->getViewConfig()->getActiveShopId();
|
||||||
@ -186,9 +189,9 @@ class d3_country_geoip extends oxAdminView
|
|||||||
if ($sCurrencies) {
|
if ($sCurrencies) {
|
||||||
foreach (unserialize($sCurrencies) as $sKey => $sValue) {
|
foreach (unserialize($sCurrencies) as $sKey => $sValue) {
|
||||||
$aFields = explode('@', $sValue);
|
$aFields = explode('@', $sValue);
|
||||||
$aCurrencies[$sKey]->id = $sKey;
|
$aCurrencies[$sKey]->id = trim($sKey);
|
||||||
$aCurrencies[$sKey]->name = $aFields[0];
|
$aCurrencies[$sKey]->name = trim($aFields[0]);
|
||||||
$aCurrencies[$sKey]->sign = $aFields[4];
|
$aCurrencies[$sKey]->sign = trim($aFields[4]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,7 +204,10 @@ class d3_country_geoip extends oxAdminView
|
|||||||
*/
|
*/
|
||||||
public function getLangList()
|
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');
|
$sShopId = $this->oCountry->getFieldData('d3geoipshop');
|
||||||
} else {
|
} else {
|
||||||
$sShopId = oxRegistry::getConfig()->getActiveView()->getViewConfig()->getActiveShopId();
|
$sShopId = oxRegistry::getConfig()->getActiveView()->getViewConfig()->getActiveShopId();
|
||||||
@ -239,12 +245,6 @@ class d3_country_geoip extends oxAdminView
|
|||||||
$oLang->sort = $aLangParams[$key]['sort'];
|
$oLang->sort = $aLangParams[$key]['sort'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($iLanguage) && $oLang->id == $iLanguage) {
|
|
||||||
$oLang->selected = 1;
|
|
||||||
} else {
|
|
||||||
$oLang->selected = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($oLang->active) {
|
if ($oLang->active) {
|
||||||
$aLanguages[$oLang->id] = $oLang;
|
$aLanguages[$oLang->id] = $oLang;
|
||||||
}
|
}
|
||||||
|
@ -307,6 +307,22 @@ class d3GeoIP extends oxbase
|
|||||||
stopProfile(__METHOD__);
|
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)
|
* check module active state and perform switching to user country specific shop (EE only)
|
||||||
*
|
*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user