chrisalism Posted November 29, 2013 Share Posted November 29, 2013 Hi, Is it possible to display different product selling prices depending on the visitors IP address? It looks like it's almost possible using the "Specific Prices" and Geolocation options, but I would like different prices to display for a particularly large customer when they visit from any of their IP addresses ( (xxx.xxx.xxx.*), rather than by Country. Can anyone suggest any tweaks I can make to the Geolocation files or another way to achieve this? Thanks! Chrisalism Link to comment Share on other sites More sharing options...
El Patron Posted November 29, 2013 Share Posted November 29, 2013 that does not exist today...i.e. grouping of ip addresses....as related to specific prices..which is by country/lang/currency only...and really the later two are seldom used. note: the native by country geo location with specific prices works perfectly with one caveat, if your ip is German and shop has specific price Germany, but your logged in registration country is not Germany, you lose the specific price at login. Link to comment Share on other sites More sharing options...
chrisalism Posted November 29, 2013 Author Share Posted November 29, 2013 Is there a way of creating a 'fake' country in Prestashop and then tricking it into thinking that any visits from that IP is from that country? Such as by adding something like: if IP_ADDR == "xxx.xxx.xxx.*" then GeoCountry = "FakeCountry" into the Geolocation files? Link to comment Share on other sites More sharing options...
El Patron Posted November 29, 2013 Share Posted November 29, 2013 file classes/controller/FrontController.php function geolocationManagement Link to comment Share on other sites More sharing options...
chrisalism Posted November 29, 2013 Author Share Posted November 29, 2013 (edited) Thanks for your help so far - much appreciated. I think I'm probably getting out of my depth, as I don't totally understand what that function is doing. To test this, I've set up a specific price on a product for the country Afghanistan (as it's first on the dropdown), then trying to hardcode in my own IP in that function to recognise it as being from Afghanistan. if (Tools::getRemoteAddr() == 'xxx.xxx.xxx.xxx') { $default_country = 'AF'; } Any idea what I'm doing wrong? Thanks again! Edited November 29, 2013 by chrisalism (see edit history) Link to comment Share on other sites More sharing options...
El Patron Posted November 30, 2013 Share Posted November 30, 2013 Thanks for your help so far - much appreciated. I think I'm probably getting out of my depth, as I don't totally understand what that function is doing. To test this, I've set up a specific price on a product for the country Afghanistan (as it's first on the dropdown), then trying to hardcode in my own IP in that function to recognise it as being from Afghanistan. if (Tools::getRemoteAddr() == 'xxx.xxx.xxx.xxx') { $default_country = 'AF'; } Any idea what I'm doing wrong? Thanks again! Do you have geo location enabled? It is required enable to execute function as for the code, I would need to see how it is placed in the actual function, not the changed lines. I have a 'similar' module, http://www.prestashop.com/forums/topic/279119-module-geo-targeting-localization-country-or-ip-simulator-pro/ Link to comment Share on other sites More sharing options...
chrisalism Posted November 30, 2013 Author Share Posted November 30, 2013 Morning, yes, I've got the geolocation enabled in geolocation preferences with all features available for behaviour and all countries ticked. Codewise, I've been attempting to add the code above in to various places within the gelocationManagement function, but with no real success - I'm a bit unsure where to place it since I don't really understand how the function works - or indeed if I'm even on the right lines. Link to comment Share on other sites More sharing options...
El Patron Posted November 30, 2013 Share Posted November 30, 2013 the problem after getting your code working is when the visitor logs in, then prestashop will replace whatever country you set to that of their registered country. Which I resolved some time ago here http://www.prestashop.com/forums/topic/193843-module-prestashop-geo-pricing-geo-target-specific-prices-by-country/ Link to comment Share on other sites More sharing options...
chrisalism Posted November 30, 2013 Author Share Posted November 30, 2013 Yes, I noticed that was happening. I'm not sure how much of an issue it'll be at this stage though. I've kinda hacked the code so that it's working now though. There seems to be a slight bug in that VAT gets added on twice for (I think) products that have combinations - although I've not really tested far enough to see if this is definitely the case. After the lookup is done on the GeoIP file: include_once(_PS_GEOIP_DIR_.'geoipcity.inc'); $gi = geoip_open(realpath(_PS_GEOIP_DIR_.'GeoLiteCity.dat'), GEOIP_STANDARD); $record = geoip_record_by_addr($gi, Tools::getRemoteAddr()); I've added the following: if (strpos(Tools::getRemoteAddr(), $customer_ip_range) === 0) { $record->continent_code = "AS"; $record->country_code = "AF"; $record->country_code3 = "AFG"; $record->country_name = "Afghanistan"; $record->region = "0"; } The other changes I've made were in the section where it looks like it's checking if a country code has already been set via a cookie, so if it matches that IP range with a cookie already set, it'll force a change there too. Any idea why VAT might be added twice on some products? Link to comment Share on other sites More sharing options...
El Patron Posted November 30, 2013 Share Posted November 30, 2013 I would back out changes and test vat to see if even related. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now