Jump to content

Default country without login or registration by IP


Recommended Posts

Purpose: to show prices with tax for people from a certain country without logging and registering.

Version PrestaShop 1.5.6.
File: config.inc.php

Search string 

$defaultCountry = new Country(Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT'));

Replace to:
 

$country_user=geoip_country_code_by_name($_SERVER['REMOTE_ADDR']); //Getting the country code by IP

if($country_user=="IL") //country Israel
{
    $defaultCountry = new Country(29, Configuration::get('PS_LANG_DEFAULT')); // 29 - Country number in the database PrestaShop
}
else
{
	$defaultCountry = new Country(Configuration::get('PS_COUNTRY_DEFAULT'), Configuration::get('PS_LANG_DEFAULT'));
}	

 

Edited by humbert (see edit history)
  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...