From a5568730a03d2be2157b55048b86dc8dd63afa3c Mon Sep 17 00:00:00 2001 From: Marvin Klein Date: Thu, 14 Jul 2022 14:41:11 +0200 Subject: [PATCH] Fix validation for custom_fields in checkout/register.php and checkout/guest.php --- upload/catalog/controller/checkout/guest.php | 4 ++++ upload/catalog/controller/checkout/register.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/upload/catalog/controller/checkout/guest.php b/upload/catalog/controller/checkout/guest.php index bdb495dc61a..f14ff845065 100644 --- a/upload/catalog/controller/checkout/guest.php +++ b/upload/catalog/controller/checkout/guest.php @@ -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'])))) { diff --git a/upload/catalog/controller/checkout/register.php b/upload/catalog/controller/checkout/register.php index 360cba439ed..262b9704aa7 100644 --- a/upload/catalog/controller/checkout/register.php +++ b/upload/catalog/controller/checkout/register.php @@ -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'])))) {