Php magento根据不工作的条件删除cookie弹出块
我必须根据条件显示magento的cookie restriction弹出块 ie)如果条件为真,则块应显示,否则不显示 我已经在CookieNotice.php中尝试了下面的方法,但是如果条件不满足,我无法获得如何删除整个块 \app\code\core\Mage\Page\Block\Html\CookieNotice.phpPhp magento根据不工作的条件删除cookie弹出块,php,magento-1.9,Php,Magento 1.9,我必须根据条件显示magento的cookie restriction弹出块 ie)如果条件为真,则块应显示,否则不显示 我已经在CookieNotice.php中尝试了下面的方法,但是如果条件不满足,我无法获得如何删除整个块 \app\code\core\Mage\Page\Block\Html\CookieNotice.php class Mage_Page_Block_Html_CookieNotice extends Mage_Core_Block_Template { public f
class Mage_Page_Block_Html_CookieNotice extends Mage_Core_Block_Template
{
public function getCookieRestrictionBlockContent()
{
$remoteAddr = Mage::helper('core/http')->getRemoteAddr(true);
$info = geoip_record_by_name($remoteAddr);
$countrycode = $info['country_code']; //IN
$allowed = Mage::getStoreConfig('general/country/eu_countries'); //AT,BE,BG,CY,CZ,DK,EE,FI,FR,DE,GR,HU,IE,IT,LV,LT,LU,MT,NL,PL,PT,RO,SK,SI,ES,SE,GB
if(in_array($countrycode, $allowed)){
echo 'match found';
$blockIdentifier = Mage::helper('core/cookie')->getCookieRestrictionNoticeCmsBlockIdentifier();
$block = Mage::getModel('cms/block')->load($blockIdentifier, 'identifier');
$html = '';
if ($block->getIsActive()) {
/* @var $helper Mage_Cms_Helper_Data */
$helper = Mage::helper('cms');
$processor = $helper->getBlockTemplateProcessor();
$html = $processor->filter($block->getContent());
}
return $html;
}
else{
// Here still the pop block appears
echo 'No match found';
}
}
}
只需抬起头。您永远无法100%信任通过IP进行的本地化。人们可以支持代理,通过VPN冲浪等。如果这是为了符合GDPR或其他法律要求,那么你应该让每个人都看到它,只是为了确保(法律通常不关心用户IP注册在哪里,只关心用户的实际位置)。是的,我必须这样做符合GDPR。。。你能帮我吗?就像我说的,给大家看看。在所有情况下,你不能100%知道请求来自何处,如果你错过了欧盟的某个人的请求,可能会很昂贵。您好@Magnueriksson,请您在代码中演示如何为欧盟的所有用户显示cookie弹出窗口,以及我需要做什么更改@Magnueriksson,我已经更新了问题,剩下的问题是如何以正确的方式获取GDPR cookie。。