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
screenshot Edit Order screen - edit_order_bug.png (23.29 KiB) Viewed 30653 times
- 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.
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
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.
Thanks for the info.Also need this file for fully working:
https://github.com/opencart/opencart/bl ... ipping.php
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
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?marco.rocci92 wrote: ↑Tue Oct 02, 2018 4:58 pmHi,
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
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
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
Attachments
Schermata 2018-10-03 alle 10.20.29.png (101.36 KiB) Viewed 29229 times
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
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 (62.93 KiB) Viewed 29181 times
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'])))) {
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') . '/')))) {
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
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));
}
}
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') )))) {
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
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'])))) {
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
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 (28 KiB) Viewed 28860 times
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!"}}
Reason: Corrected my username and added code tags.
Using OC Version 3.0.3.2
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->getTotal()
#1 /home/ihateusernames/shop.indonesianwholesaler.com/catalog/controller/api/payment.php(146): Loader->{closure}(Array, Array, 0)
#2 /home/ihateusernames/ocartdataclone/storage/modification/system/engine/action.php(78): ControllerApiPayment->methods()
#3 /home/ihateusernames/shop.indonesianwholesaler.com/catalog/controller/startup/router.php(25): Action->execute(Object(Registry))
#4 /home/ihateusernames/ocartdataclone/storage/modification/system/engine/action.php(78): ControllerStartupRouter->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 />
Reason: Added code tags.
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.
Users browsing this forum: No registered users and 143 guests