Post by ossandust » Tue Aug 29, 2017 4:02 am

OpenCart v.3.0.2.0
I added a few required custom fields to the customer details page. When I try to edit an existing order I'm stuck on the first tab, with a "field required!" error message appearing next to each required custom field, although all required fields are filled in. (screenshot attached)

Attachments

edit_order_bug.png

screenshot Edit Order screen - edit_order_bug.png (23.29 KiB) Viewed 30528 times


Newbie

Posts

Joined
Thu Aug 24, 2017 3:51 am

Post by straightlight » Wed Nov 15, 2017 6:00 am

Updated steps:

- https://github.com/opencart/opencart/bl ... stomer.php
- https://github.com/opencart/opencart/bl ... ayment.php

Clear your OC cache afterwards from the OC admin. This should resolved the issue.
Last edited by straightlight on Wed Mar 14, 2018 6:24 pm, edited 1 time in total.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by stashdesign » Wed Mar 14, 2018 4:18 am

I also have the exact same problem. Someone please help me solve it.. Try to fix it for the last 8 hours!

Newbie

Posts

Joined
Fri Oct 06, 2017 2:40 am

Post by straightlight » Wed Mar 14, 2018 6:23 pm

You have the exact same problem but without providing the OC version. Of course. There was a recent topic solution on my behalf but can no longer seem to find it. I have now updated the steps above.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by stashdesign » Wed Mar 14, 2018 7:49 pm

That solved my problem! Many thanks!

Also need this file for fully working:
https://github.com/opencart/opencart/bl ... ipping.php

Btw i am on version 3.0.2.0 OCMOD.

Newbie

Posts

Joined
Fri Oct 06, 2017 2:40 am

Post by straightlight » Wed Mar 14, 2018 9:26 pm

Also need this file for fully working:
https://github.com/opencart/opencart/bl ... ipping.php
Thanks for the info.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by straightlight » Thu Mar 15, 2018 12:03 am

Found the actual topic: viewtopic.php?f=201&t=202036#p713641

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by marco.rocci92 » Tue Oct 02, 2018 4:58 pm

Hi,
there is error when using custom errors with Regex like
/^[a-zA-Z]{6}[0-9]{2}[abcdehlmprstABCDEHLMPRST]{1}[0-9]{2}([a-zA-Z]{1}[0-9]{3})[a-zA-Z]{1}$/

the problem is on ^ character

Newbie

Posts

Joined
Sun Jan 21, 2018 10:30 pm

Post by straightlight » Wed Oct 03, 2018 4:07 am

marco.rocci92 wrote:
Tue Oct 02, 2018 4:58 pm
Hi,
there is error when using custom errors with Regex like
/^[a-zA-Z]{6}[0-9]{2}[abcdehlmprstABCDEHLMPRST]{1}[0-9]{2}([a-zA-Z]{1}[0-9]{3})[a-zA-Z]{1}$/

the problem is on ^ character
More information needed. Which route and location are you describing this issue from?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by marco.rocci92 » Wed Oct 03, 2018 4:22 pm

I retried and now it work, but there is a problem on the length of the regex like:

Code: Select all

/^(?:(?:[B-DF-HJ-NP-TV-Z]|[AEIOU])[AEIOU][AEIOUX]|[B-DF-HJ-NP-TV-Z]{2}[A-Z]){2}[\dLMNP-V]{2}(?:[A-EHLMPR-T](?:[04LQ][1-9MNP-V]|[1256LMRS][\dLMNP-V])|[DHPS][37PT][0L]|[ACELMRT][37PT][01LM])(?:[A-MZ][1-9MNP-V][\dLMNP-V]{2}|[A-M][0L](?:[1-9MNP-V][\dLMNP-V]|[0L][1-9MNP-V]))[A-Z]$/i
opencart trunc the regex when save

Attachments

Schermata 2018-10-03 alle 10.20.29.png

Schermata 2018-10-03 alle 10.20.29.png (101.36 KiB) Viewed 29104 times


Newbie

Posts

Joined
Sun Jan 21, 2018 10:30 pm

Post by straightlight » Wed Oct 03, 2018 5:57 pm

Not a bug. Posted in wrong section.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by marco.rocci92 » Sat Oct 06, 2018 1:35 am

i edited the file, now it is like https://github.com/opencart/opencart/bl ... stomer.php
but now i have problem:
the regex of custom field is /^[A-Z]{6}\d{2}[A-Z]\d{2}[A-Z]\d{3}[A-Z]$/i
when i press continue, i have error on filter_var

Attachments

Schermata 2018-10-05 alle 19.09.56.png

Schermata 2018-10-05 alle 19.09.56.png (62.93 KiB) Viewed 29056 times


Newbie

Posts

Joined
Sun Jan 21, 2018 10:30 pm

Post by straightlight » Sat Oct 06, 2018 7:58 pm

Already fixed on Github. In catalog/controller/api/customer.php file,

find:

Code: Select all

} elseif (($custom_field['type'] == 'text') && !empty($custom_field['validation']) && !filter_var($this->request->post['custom_field'][$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $custom_field['validation'])))) {
replace with:

Code: Select all

} elseif (($custom_field['type'] == 'text') && !empty($custom_field['validation']) && filter_var($this->request->post['custom_field'][$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/' . html_entity_decode($custom_field['validation'], ENT_QUOTES, 'UTF-8') . '/')))) {
This should resolved the issue.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by marco.rocci92 » Sun Oct 07, 2018 3:47 am

Thanks for the answer.
My catalog/controller/api/customer.php
is like your:

Code: Select all

<?php
class ControllerApiCustomer extends Controller {
	public function index() {
		$this->load->language('api/customer');
		// Delete past customer in case there is an error
		unset($this->session->data['customer']);
		$json = array();
		if (!isset($this->session->data['api_id'])) {
			$json['error']['warning'] = $this->language->get('error_permission');
		} else {
			// Add keys for missing post vars
			$keys = array(
				'customer_id',
				'customer_group_id',
				'firstname',
				'lastname',
				'email',
				'telephone',
			);
			foreach ($keys as $key) {
				if (!isset($this->request->post[$key])) {
					$this->request->post[$key] = '';
				}
			}
			// Customer
			if ($this->request->post['customer_id']) {
				$this->load->model('account/customer');
				$customer_info = $this->model_account_customer->getCustomer($this->request->post['customer_id']);
				if (!$customer_info || !$this->customer->login($customer_info['email'], '', true)) {
					$json['error']['warning'] = $this->language->get('error_customer');
				}
			}
			if ((utf8_strlen(trim($this->request->post['firstname'])) < 1) || (utf8_strlen(trim($this->request->post['firstname'])) > 32)) {
				$json['error']['firstname'] = $this->language->get('error_firstname');
			}
			if ((utf8_strlen(trim($this->request->post['lastname'])) < 1) || (utf8_strlen(trim($this->request->post['lastname'])) > 32)) {
				$json['error']['lastname'] = $this->language->get('error_lastname');
			}
			if ((utf8_strlen($this->request->post['email']) > 96) || (!filter_var($this->request->post['email'], FILTER_VALIDATE_EMAIL))) {
				$json['error']['email'] = $this->language->get('error_email');
			}
			if ((utf8_strlen($this->request->post['telephone']) < 3) || (utf8_strlen($this->request->post['telephone']) > 32)) {
				$json['error']['telephone'] = $this->language->get('error_telephone');
			}
			// Customer Group
			if (is_array($this->config->get('config_customer_group_display')) && in_array($this->request->post['customer_group_id'], $this->config->get('config_customer_group_display'))) {
				$customer_group_id = $this->request->post['customer_group_id'];
			} else {
				$customer_group_id = $this->config->get('config_customer_group_id');
			}
			// Custom field validation
			$this->load->model('account/custom_field');
			$custom_fields = $this->model_account_custom_field->getCustomFields($customer_group_id);
			foreach ($custom_fields as $custom_field) {
				if ($custom_field['location'] == 'account') {
					if ($custom_field['required'] && empty($this->request->post['custom_field'][$custom_field['custom_field_id']])) {
						$json['error']['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']);
					} elseif (($custom_field['type'] == 'text') && !empty($custom_field['validation']) && filter_var($this->request->post['custom_field'][$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/' . html_entity_decode($custom_field['validation'], ENT_QUOTES, 'UTF-8') . '/')))) {
						$json['error']['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']);
					}
				}
			}
			if (!$json) {
				$this->session->data['customer'] = array(
					'customer_id'       => $this->request->post['customer_id'],
					'customer_group_id' => $customer_group_id,
					'firstname'         => $this->request->post['firstname'],
					'lastname'          => $this->request->post['lastname'],
					'email'             => $this->request->post['email'],
					'telephone'         => $this->request->post['telephone'],
					'custom_field'      => isset($this->request->post['custom_field']) ? $this->request->post['custom_field'] : array()
				);
				$json['success'] = $this->language->get('text_success');
			}
		}
		$this->response->addHeader('Content-Type: application/json');
		$this->response->setOutput(json_encode($json));
	}
}
but i have the same issue

Newbie

Posts

Joined
Sun Jan 21, 2018 10:30 pm

Post by marco.rocci92 » Sun Oct 07, 2018 5:02 am

You gave me this code
replace with:

Code: Select all

} elseif (($custom_field['type'] == 'text') && !empty($custom_field['validation']) && filter_var($this->request->post['custom_field'][$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/' . html_entity_decode($custom_field['validation'], ENT_QUOTES, 'UTF-8') . '/')))) {

but
i read code on the register.php where there is a similar filter_var (where maybe it should be change integrating the html_entity_decode)
then maybe the code should be:

Code: Select all

} elseif (($custom_field['type'] == 'text') && !empty($custom_field['validation']) && !filter_var($this->request->post['custom_field'][$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, array('options' => array('regexp' =>  html_entity_decode($custom_field['validation'], ENT_QUOTES, 'UTF-8') )))) {
I tested and it work
what do you think about?
I removed the concatenation of html_entity_decode because the string have the '/' . and i put the negation in filter_var

Newbie

Posts

Joined
Sun Jan 21, 2018 10:30 pm

Post by straightlight » Sun Oct 07, 2018 10:19 am

In catalog/controller/account/register.php file,

find:

Code: Select all

} elseif (($custom_field['type'] == 'text') && !empty($custom_field['validation']) && !filter_var($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $custom_field['validation'])))) {
replace with:

Code: Select all

} elseif (($custom_field['type'] == 'text') && !empty($custom_field['validation']) && filter_var($this->request->post['custom_field'][$custom_field['location']][$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => '/' . html_entity_decode($custom_field['validation'], ENT_QUOTES, 'UTF-8') . '/')))) {

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by qualitas » Mon Nov 12, 2018 10:14 am

I have a specific order blocked on step 4 "shipping details" without having done any modification yet.
No error message and no error log.

I want to add shipping fees on step 5 but cannot access it. (product is too big for postal service and didn't calculate it).

First I taught it's a Regex problem because of a French character but I change it and it's still not going to tab 5.

I just updated those 4 files:
https://github.com/opencart/opencart/bl ... stomer.php
https://github.com/opencart/opencart/bl ... ayment.php
https://github.com/opencart/opencart/bl ... ipping.php
https://github.com/opencart/opencart/bl ... gister.php

And it still not work.

Here the order details (see attachment picture):

Attachments

Capture du 2018-11-11 21-03-43.png

Capture du 2018-11-11 21-03-43.png (28 KiB) Viewed 28735 times


New member

Posts

Joined
Mon Mar 26, 2018 9:27 am

Post by ihateusernames » Wed Sep 25, 2019 3:09 pm

Hi,

I am experiencing the same issue. I've copied & pasted the two php files as suggested by Straightlight but I now get an error pop up instead. This reads....

Code: Select all

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
OK
<b>Warning</b>: filter_var(): Unknown modifier '[' in <b>/home/ihateusernames/shop.indonesianwholesaler.com/catalog/controller/api/customer.php</b> on line <b>58</b><b>Warning</b>: filter_var(): Unknown modifier '[' in <b>/home/ihateusernames/shop.indonesianwholesaler.com/catalog/controller/api/customer.php</b> on line <b>58</b><b>Warning</b>: filter_var(): Unknown modifier '[' in <b>/home/ihateusernames/shop.indonesianwholesaler.com/catalog/controller/api/customer.php</b> on line <b>58</b>{"error":{"custom_field4":"Country required!"}}
Any solution welcomed. Thanks.
Last edited by straightlight on Fri Jan 31, 2020 11:21 am, edited 1 time in total.
Reason: Corrected my username and added code tags.

Using OC Version 3.0.3.2


Active Member

Posts

Joined
Wed Jul 24, 2019 10:31 am

Post by ihateusernames » Sun Oct 06, 2019 4:50 pm

Hi,

I've now disabled the custom fields but I still get this Syntax error...:

Code: Select all

SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
OK
<br />
<b>Fatal error</b>:  Uncaught ArgumentCountError: Too few arguments to function ModelExtensionTotalSubTotal::getTotal(), 0 passed in /home/ihateusernames/ocartdataclone/storage/modification/system/engine/loader.php on line 248 and exactly 1 expected in /home/ihateusernames/shop.indonesianwholesaler.com/catalog/model/extension/total/sub_total.php:3
Stack trace:
#0 /home/ihateusernames/ocartdataclone/storage/modification/system/engine/loader.php(248): ModelExtensionTotalSubTotal-&gt;getTotal()
#1 /home/ihateusernames/shop.indonesianwholesaler.com/catalog/controller/api/payment.php(146): Loader-&gt;{closure}(Array, Array, 0)
#2 /home/ihateusernames/ocartdataclone/storage/modification/system/engine/action.php(78): ControllerApiPayment-&gt;methods()
#3 /home/ihateusernames/shop.indonesianwholesaler.com/catalog/controller/startup/router.php(25): Action-&gt;execute(Object(Registry))
#4 /home/ihateusernames/ocartdataclone/storage/modification/system/engine/action.php(78): ControllerStartupRouter-&gt;index()
#5 /home/ihateusernames/shop.indonesianwholes in <b>/home/ihateusernames/shop.indonesianwholesaler.com/catalog/model/extension/total/sub_total.php</b> on line <b>3</b><br />
If anyone has a fix for this issue it would be greatly appreciated, thanks.
Last edited by straightlight on Fri Jan 31, 2020 11:21 am, edited 1 time in total.
Reason: Added code tags.

Active Member

Posts

Joined
Wed Jul 24, 2019 10:31 am

Post by Zest 365 » Sun Nov 17, 2019 5:58 pm

Hi All,

For those who are having the same issue but on OC Version 3.0.3.2 please read this.
I have fixed this issue by using "Straightlight's" fix to "catalog/controller/api/customer.php" file.

A Massive Thank You to "Straightlight".

The path to this file is as follows;
https://github.com/opencart/opencart/bl ... stomer.php

Please see the attached file for screenshot of my Order Edit and confirmation email to customer (showing custom field) following updating the above file.

Attachments


Newbie

Posts

Joined
Sun May 24, 2015 5:55 pm
Location - Bradford, UK
Who is online

Users browsing this forum: No registered users and 34 guests