Jump to content

default country not selected on customer registration


Recommended Posts

Hi,

 

I only have 2 countries enabled in my shop. Belgium (which is the default country) and the Netherlands.

The database shows that Belgium in fact is default. (country ID 3 = Belgium) PS_COUNTRY_DEFAULT 3

 

On a customer registration the pre-selected country is Netherlands.

Is there any way to change this to Belgium?

Can't find any reference of Netherlands in the database which I could change to Belgium...

 

Kind regards

Link to comment
Share on other sites

Hello,

 

I have never done that, but I would look for country selection and see if there is no way to force it in the template to select Belgium by default based on the language selection the customer is logged in with or the country the customer selected.

 

Try adding {debug} at the end of authentication.tpl to see which Smarty variables are exported and use that in the template to adapt the logic display. This might help you.

 

Hope this helps!

 

BR,

RaPhiuS

Link to comment
Share on other sites

  • 3 weeks later...

I compared both files, my authentication.tpl and the original one. Seems to be no differences between them.

Same problem here, original authentication.tpl

The problem is only on the address creation, (address.tpl) and not on authentication.tpl

When I change the ISO code of Netherlands in BO to ex. NLL Belgium is selected first

But this isn't a good work around

 

Br,

E-raser

Edited by E-raser (see edit history)
Link to comment
Share on other sites

  • 7 months later...

Hi guys, late reply, but this was also bugging me today. Found a workaround by commenting out part of assigncountries() function in AddressController.php (do it in an override of course. The resulting AddressController override looks like this, worked for me:

<?php
/*
*
*  Remove if loop that bugs out default country selection...
*
*  @author 
* 
*/

class AddressController extends AddressControllerCore
{
	/**
	 * Assign template vars related to countries display
	 */
	protected function assignCountries()
	{
		// Get selected country
		if (Tools::isSubmit('id_country') && !is_null(Tools::getValue('id_country')) && is_numeric(Tools::getValue('id_country')))
			$selected_country = (int)Tools::getValue('id_country');
		else if (isset($this->_address) && isset($this->_address->id_country) && !empty($this->_address->id_country) && is_numeric($this->_address->id_country))
			$selected_country = (int)$this->_address->id_country;
		/*else if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']))
		{
			// get all countries as language (xy) or language-country (wz-XY)
			$array = array();
			preg_match("#(?<=-)\w\w|\w\w(?!-)#",$_SERVER['HTTP_ACCEPT_LANGUAGE'],$array);
			if (!Validate::isLanguageIsoCode($array[0]) || !($selected_country = Country::getByIso($array[0])))
				$selected_country = (int)Configuration::get('PS_COUNTRY_DEFAULT');
		}*/
		else
			$selected_country = (int)Configuration::get('PS_COUNTRY_DEFAULT');

		// Generate countries list
		if (Configuration::get('PS_RESTRICT_DELIVERED_COUNTRIES'))
			$countries = Carrier::getDeliveredCountries($this->context->language->id, true, true);
		else
			$countries = Country::getCountries($this->context->language->id, true);

		// @todo use helper
		$list = '';
		foreach ($countries as $country)
		{
			$selected = ($country['id_country'] == $selected_country) ? 'selected="selected"' : '';
			$list .= '<option value="'.(int)$country['id_country'].'" '.$selected.'>'.htmlentities($country['name'], ENT_COMPAT, 'UTF-8').'</option>';
		}

		// Assign vars
		$this->context->smarty->assign(array(
			'countries_list' => $list,
			'countries' => $countries,
		));
	}
}
  • Like 1
Link to comment
Share on other sites

  • 1 year later...

Hi all,

 

My default country is the UK, yet when someone from the UK signs up, the United States is pre-selected. I've tried the override from the above post but it didn't do anything. Also, these posts are a few years old.

 

So is there a way to make the UK the default country for the address field for new customers registrations?

 

Any help greatly appreciated.

 

Cheers,

CP.

 

Posted on a new thread as this seems to be in the wrong forum and a very old thread:

https://www.prestashop.com/forums/topic/473858-set-default-country-as-pre-selected-country-on-customer-registration-address/

Edited by carpygmy (see edit history)
Link to comment
Share on other sites

  • 4 months later...
Forget the codes and programming. The solution is very simple.

 

Location --- Countries --- edit country and simply add a space before the name of the country who wish to appear first in the customer registration ;)
 
Greetings from Chile
  • Like 1
Link to comment
Share on other sites

×
×
  • Create New...