When the customer enters their email address there is sometimes a space at the end of the email which throws up an error on the checkout so I want to trim the space from the end of the email before is validated from the below code;
if ((utf8_strlen($this->request->post['personal_details']['email']) > 96) || !filter_var($this->request->post['personal_details']['email'], FILTER_VALIDATE_EMAIL)) {
I have tried and tried to do this but don't understand php so any help would be much appreciated.
Thanks,
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
I followed your instructions changing the existing lines of code to the below in system/library/mail.php
public function setTo($to) {
$this->to = trim($to);
}
public function setFrom($from) {
$this->from = trim($from);
}
I then cleared the opencart cache and also the modification cache, I also cleared the browser history/cookies etc but the problem still persists
For example if there is a space at the end of the email address when the customer is checking out (which is caused by the predictive input from mobile phones - a space is generated at the end of each word ready for the next word to space them apart) the customer is not allowed to proceed through the checkout and they abandon their cart as they don't know why their email isn't being accepted.
Also, I have noticed that if there is a space at the end of any of the other address fields this doesn't cause any problems - it just seems to be the email field.
Thanks
find all instances of:
Code: Select all
$this->db->escape(utf8_strtolower($email))
Code: Select all
$this->db->escape(trim(utf8_strtolower($email)))
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Attachments
2018-08-28 14_50_54-Checkout.png (29.46 KiB) Viewed 6173 times
find:
Code: Select all
if ((utf8_strlen($this->request->post['email']) > 96) || !filter_var($this->request->post['email'], FILTER_VALIDATE_EMAIL)) {
Code: Select all
$this->request->post['email'] = trim($this->request->post['email']);
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
$this->request->post['email'] = trim($this->request->post['email']);
Were does it need to go in relation to this code:
if ((utf8_strlen($this->request->post['email']) > 96) || !filter_var($this->request->post['email'], FILTER_VALIDATE_EMAIL)) {
For example, does it need to go above/below or at the end of it etc
Thanks,
add above:
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
find:
Code: Select all
public function clean($data) {
if (is_array($data)) {
foreach ($data as $key => $value) {
unset($data[$key]);
$data[$this->clean($key)] = $this->clean($value);
}
} else {
$data = htmlspecialchars($data, ENT_COMPAT, 'UTF-8');
}
return $data;
}
Code: Select all
public function clean($data) {
if (is_array($data)) {
foreach ($data as $key => $value) {
unset($data[$key]);
$data[$this->clean($key)] = $this->clean($value);
}
$this->arrayMapRecursive('trim', $data);
} else {
$data = htmlspecialchars(trim($data), ENT_COMPAT, 'UTF-8');
}
return $data;
}
// Source: https://stackoverflow.com/questions/47298576/how-do-i-remove-surrounding-spaces-from-each-value-in-multidimensional-array-rec
protected function arrayMapRecursive(callable $func, array $array) {
return filter_var($array, \FILTER_CALLBACK, ['options' => $func]);
}
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
I know this thread is bit outdated. I had an issue with "not valid email" registration error and tried the code from the suggestion above - changing the piece inside register.php file. It worked fine on the email fields but we started getting all sorts of errors on the front and back-end and I had to revert back to original file. I'm using v. 3.0.3.1 with Journal 3.
Should that code be updated to work?
No error logs provided.redlik7 wrote: ↑Thu Feb 20, 2020 8:54 pmHI,
I know this thread is bit outdated. I had an issue with "not valid email" registration error and tried the code from the suggestion above - changing the piece inside register.php file. It worked fine on the email fields but we started getting all sorts of errors on the front and back-end and I had to revert back to original file. I'm using v. 3.0.3.1 with Journal 3.
The code itself works, according to the above statement.Should that code be updated to work?
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
I got these errors on the front-end (screenshots)straightlight wrote: ↑Thu Feb 20, 2020 8:57 pmNo error logs provided.redlik7 wrote: ↑Thu Feb 20, 2020 8:54 pmHI,
I know this thread is bit outdated. I had an issue with "not valid email" registration error and tried the code from the suggestion above - changing the piece inside request.php file. It worked fine on the email fields but we started getting all sorts of errors on the front and back-end and I had to revert back to original file. I'm using v. 3.0.3.1 with Journal 3.
The code itself works, according to the above statement.Should that code be updated to work?


and this in the errors log:
Code: Select all
2020-02-20 10:55:38 - PHP Warning: Cannot modify header information - headers already sent by (output started at osmarine.ie/system/framework.php:42) in osmarine.ie/system/framework.php on line 108
2020-02-20 10:55:38 - PHP Warning: Invalid argument supplied for foreach() in /storageosm/modification/admin/controller/catalog/product.php on line 1252
2020-02-20 10:55:38 - PHP Warning: Invalid argument supplied for foreach() in /storageosm/modification/admin/model/catalog/product.php on line 146
2020-02-20 10:55:38 - PHP Warning: Cannot modify header information - headers already sent by (output started at /marinedistributors.ie/osmarine.ie/system/framework.php:42) in //marinedistributors.ie/storageosm/modification/system/library/response.php on line 36
2
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester

Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
I can downgrade the version, if you think that's going to help. But to which version?straightlight wrote: ↑Thu Feb 20, 2020 10:20 pmPerhaps some changes with the array_map function were applied from the industry since. May be looking on StackOverFlow by using Google to find the most recent solution.![]()
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
Users browsing this forum: No registered users and 19 guests