Jump to content

Set cookie country from POST or default country in link to pre-select country


coMegaWebMaster
 Share

Recommended Posts

Greetings,

Am trying to set in the country ID or ISO value within the link to pre-select the country. This is due that counties in EU have tax set in the price and out of EU the prices are without tax and if I send now an link to a customer they are not getting the price they should see.
I already have the code to set the correct currency and that is working fine, but not for the country and I hope here someone can help.

An example of what I want is:
www.demoshop.demo/en/categorie/product.html?the_country=24
OR
www.demoshop.demo/en/categorie/product.html?the_country=AU
that will result in pre-selecting Australia in this case, so also when you go to the checkout page that the country is already selected.

What I have so far in /override/classes/Tools.php for this, but does not work yet:

	public static function setCountry($cookie)
	{
		if (self::getIsset('the_country') && is_numeric(self::getValue('the_country'))) {
			$country = Country::getCountryInstance((int)(Tools::getValue('the_country')));
			if (is_object($country) && $country->id && !$country->deleted && $country->isAssociatedToShop()) {
				$cookie->id_country = (int)$country->id;
			}
		}


With kind regards,
Alexander.

Share this post


Link to post
Share on other sites

an option to consider

https://addons.prestashop.com/en/international-localization/27368-geo-targeting-pro-by-country-prices-taxes-currency-.html?pab=1&

basically then when they enter shop from their country, non-logged, they see their country catalog

note:  module supports two maxmin commerical db's and our clients are getting 99.75% resolve rate, the module has resolve insights.

maybe no help for your current situation, but if you are international company....I am giant in geo lol

happy selling

Share this post


Link to post
Share on other sites

Hi El Patron,

I had a look at your module, but am afraid that this will not help me in this case. I really need to give a link that will pre-select the country no-matter where they are (or using a VPN), as what I already have with currencies now what is working. But I think am over-complicating or overthinking it and not seeing the obvious solution.

Just want to add in the link ?the_country=24 or ?the_country=AU, like:
www.demoshop.demo/en/categorie/product.html?the_currency=23?the_country=24
OR
www.demoshop.demo/en/categorie/product.html?the_currency=AUD?the_country=AU
that will result in pre-selecting Australia in this case.

Tomorrow I will re-look it with the information I got from jsonPTS and hopefully I can get it to work, but am open to suggestions :)

With kind regards,
Alexander.

Share this post


Link to post
Share on other sites

  • 4 years later...

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
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More