Please check Below code. I have try to get customer country code on footer.phtml. I have used GeoIP plugin to get. And added this code to block. Anyone let me know that How can I get this code out of a cache.
Issue: currently all visitor get the same county due to load this block from the cache.
namespace Rokanthemes\Themeoption\Block;
class Themeoption extends \Magento\Framework\View\Element\Template
{
public $geoIpService;
public function __construct(
\MagePal\GeoIp\Service\GeoIpService $geoIpService,
array $data = []
) {
$this->geoIpService = $geoIpService;
parent::__construct($context, $data);
}
public function ipCountry()
{
return $this->geoIpService->getCountry();
}
}