Skip to content

Commit

Permalink
Merge pull request #11464 from MarvinKlein1508/3.0.x.x_Maintenance
Browse files Browse the repository at this point in the history
Fix validation for custom_fields in checkout
  • Loading branch information
mhcwebdesign committed Jul 14, 2022
2 parents 98fc451 + a556873 commit 4a8ed58
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions upload/catalog/controller/checkout/guest.php
Expand Up @@ -215,6 +215,10 @@ public function save() {
$custom_fields = $this->model_account_custom_field->getCustomFields($customer_group_id);

foreach ($custom_fields as $custom_field) {
if($custom_field['location'] == 'affiliate') {
continue;
}

if ($custom_field['required'] && empty($this->request->post['custom_field'][$custom_field['location']][$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['location']][$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $custom_field['validation'])))) {
Expand Down
4 changes: 4 additions & 0 deletions upload/catalog/controller/checkout/register.php
Expand Up @@ -186,6 +186,10 @@ public function save() {
$custom_fields = $this->model_account_custom_field->getCustomFields($customer_group_id);

foreach ($custom_fields as $custom_field) {
if($custom_field['location'] == 'affiliate') {
continue;
}

if ($custom_field['required'] && empty($this->request->post['custom_field'][$custom_field['location']][$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['location']][$custom_field['custom_field_id']], FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $custom_field['validation'])))) {
Expand Down

0 comments on commit 4a8ed58

Please sign in to comment.