Post by vourlismenos » Sun Aug 03, 2025 8:09 pm

For oc 3.0.3.2

I've building a modification in order to add two extra fields in the shipping address only - so I'm not using the default custom fields capability.
It's working fine, but one of the fields I'm adding is an additional email field (for shipping purposes only). It's a required field and I need to validate, so I'm sure they won't leave it empty.

I've managed to make it validate for guest shipping and when a registered user adds a new address in the checkout.
But I can't make it validate in the user's address book - when they edit or add a new address from there.

In catalog/controller/account/address.php I've added:

Code: Select all

if ((utf8_strlen(trim($this->request->post['telephone2'])) < 1) || (utf8_strlen(trim($this->request->post['telephone2'])) > 32)) {
			$this->error['telephone2'] = $this->language->get('error_telephone');
		}
The same way worked in the other cases, but I can't make it work now... Should I be looking somewhere else as well?

New member

Posts

Joined
Wed Dec 05, 2018 5:01 pm

Post by khnaz35 » Mon Aug 04, 2025 1:12 am

If the validation is failing in the account address section, it's almost always due to either:

The field not being included in the POST request (check the template)
Or not populating $data['telephone2'], which breaks the error message rendering
Or missing database logic to handle loading/saving that field

Got a burning question at 3 AM that even Google shrugs at? There’s a not-so-secret inbox that might just have your answer: khnaz35@gmail.com
Breathe in some nature while you're at it. It’s cheaper than therapy. :-*

Feel free to sling a bear my way via PayPal @ khnaz35@gmail.com


User avatar
Active Member

Posts

Joined
Mon Aug 27, 2018 11:30 pm
Location - Malaysia

Post by vourlismenos » Mon Aug 04, 2025 1:46 pm

The post request is in the controller as far as I can see.
in catalog/controller/account/address.php I've added:

Code: Select all

if (isset($this->request->post['telephone2'])) {
						$data['telephone2'] = $this->request->post['telephone2'];
					} elseif (!empty($address_info)) {
						$data['telephone2'] = $address_info['telephone2'];
					} else {
						$data['telephone2'] = '';
					}
and

Code: Select all

if ((utf8_strlen(trim($this->request->post['telephone2'])) < 1) || (utf8_strlen(trim($this->request->post['telephone2'])) > 32)) {
			$this->error['telephone2'] = $this->language->get('error_telephone');
		}
If the field is filled in, the details are saved and the database populated, so the rest of the modifications works :/


khnaz35 wrote:
Mon Aug 04, 2025 1:12 am
If the validation is failing in the account address section, it's almost always due to either:

The field not being included in the POST request (check the template)
Or not populating $data['telephone2'], which breaks the error message rendering
Or missing database logic to handle loading/saving that field

New member

Posts

Joined
Wed Dec 05, 2018 5:01 pm
Who is online

Users browsing this forum: No registered users and 38 guests