Jump to content

Separating street Address and street Number


Donnerberg

Recommended Posts

Hello,

I wish to separate Address textbox to Street name and Street number.

Some customers writes just a street name ( with out street number ) and then we can not sent package. Also we lose sometimes and few days before we contact customer and get the street number from him.

 

For example instead of "Downing Street 5" I wish two different fields Street name: "Downing Street:" and under that Street number: "5" 

Thanks for answer !

Link to comment
Share on other sites

  • 1 year later...

I solved this problem by checking for a number in the address fields. That way there is no extra field. Of course it will give false positives with some street names that contain a number, but I think that problem is marginal.

What I did was adapting the function processSubmitAccount() in controllers/front/authController.php. In my PS version (1.6.0.14) that is around line 407. I added the following code (the first two and last lines are in the original to give you context):

		if ($error_phone)
			$this->errors[] = Tools::displayError('You must register at least one phone number.');
		$address1 = Tools::getValue('address1');
		$address2 = Tools::getValue('address2');
		if($address1 != "")
		{ if((!preg_match('/[0-9]/', $address1)) && (!preg_match('/[0-9]/', $address2)))
		    $this->errors[] = Tools::displayError('You must provide a house number.');
		}
		$this->errors = array_unique(array_merge($this->errors, $customer->validateController()));

Of course you can make this an override.

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

  • 2 years later...
On 2/22/2018 at 7:05 AM, musicmaster said:

I solved this problem by checking for a number in the address fields. That way there is no extra field. Of course it will give false positives with some street names that contain a number, but I think that problem is marginal.

What I did was adapting the function processSubmitAccount() in controllers/front/authController.php. In my PS version (1.6.0.14) that is around line 407. I added the following code (the first two and last lines are in the original to give you context):


		if ($error_phone)
			$this->errors[] = Tools::displayError('You must register at least one phone number.');
		$address1 = Tools::getValue('address1');
		$address2 = Tools::getValue('address2');
		if($address1 != "")
		{ if((!preg_match('/[0-9]/', $address1)) && (!preg_match('/[0-9]/', $address2)))
		    $this->errors[] = Tools::displayError('You must provide a house number.');
		}
		$this->errors = array_unique(array_merge($this->errors, $customer->validateController()));

Of course you can make this an override.

 

Hi there, i tried this in my PS 1.6.1.10 but it's not working. I have a authController.php in my override folder and I also did the change there, no effects. Is this code correct?? Why the 'if ($error_phone)' condition is not followed by a { ????

This is my original authController.php file lines:

if ($error_phone) {
            $this->errors[] = Tools::displayError('You must register at least one phone number.');
        }

        $this->errors = array_unique(array_merge($this->errors, $customer->validateController()));
 

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...