T
T
TommyEL2021-06-29 13:37:38
opencart
TommyEL, 2021-06-29 13:37:38

Error when editing order Opencart 3.0.2?

Good afternoon, tell me how to fix the error. In the admin panel, when editing an order, an error occurs

storage/modification/catalog/controller/api/customer.php on line 81
or
catalog/controller/api/customer.php on line 81

{"error": {"custom_field1":\u041e\. ..........\u0433\u0433) required!", "custom_field2":" ...................... required!"} }

I believe that we created custom fields for filling by the client and now the system swears at them, here is the code from line 81

}  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'])))) {
            $json['error']['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']); 
          }


Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
TommyEL, 2021-07-09
@TommyEL

I found a solution to the problem on the form here
in the \catalog\controller\api\customer.php file
, replace lines from 69 to 77 with:

foreach ($custom_fields as $custom_field) {
                if ($custom_field['location'] == 'account') {
                    foreach ($this->request->post['custom_field'] as $posted_key => $posted_value) {
                        if ((int)$posted_key == (int)$custom_field['custom_field_id']) {
                            if (empty($posted_value) && $custom_field['required']) {
                                $json['error']['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']);
                            } elseif ((html_entity_decode(trim(strtolower($custom_field['type'])), ENT_QUOTES, 'UTF-8') == 'text') && !empty($custom_field['validation']) && !filter_var($posted_value, FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $custom_field['validation'])))) {
                                $json['error']['custom_field' . $custom_field['custom_field_id']] = sprintf($this->language->get('error_custom_field'), $custom_field['name']);
                            }
                        }
                    }
                }
            }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question