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

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


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.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


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.

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


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

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


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?

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


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

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


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

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


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') . '/')))) {

The most generated errors being found on Opencart forum originates from contributed programming. The increased post counters are caused by redundancies of the same solutions that were already provided prior.

F. Rules:

- viewtopic.php?f=176&t=200480
- viewtopic.php?f=176&t=200804


Regards,
Straightlight


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 300 times


New member

Posts

Joined
Mon Mar 26, 2018 9:27 am
Who is online

Users browsing this forum: No registered users and 4 guests