Skip to content

Commit 7be081e

Browse files
committed
ACP2E-182: Error while validating Store VAT Number
1 parent 23d0903 commit 7be081e

File tree

1 file changed

+7
-13
lines changed
  • app/code/Magento/Config/view/adminhtml/templates/system/config

1 file changed

+7
-13
lines changed

app/code/Magento/Config/view/adminhtml/templates/system/config/js.phtml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ script;
7979
$scriptString .= 'this.regionsUrl = "' . $block->escapeJs($block->getUrl('directory/json/countryRegion')) . '";';
8080
$countryFilter = $block->getData('countryFilter');
8181
$euCountries = $countryFilter->getEuCountryList();
82-
$scriptString .= 'this.euCountryList = ' . json_encode($euCountries);
82+
$scriptString .= 'this.euCountryList = Object.values(' . json_encode($euCountries) . ');';
8383

8484
$scriptString .= <<<script
8585
@@ -101,7 +101,6 @@ $scriptString .= <<<script
101101
},
102102
reloadVatNumberField : function(event)
103103
{
104-
this.reload = true;
105104
var countryElement = Event.element(event);
106105
if (countryElement && countryElement.id) {
107106
this.refreshVatNumberField(countryElement);
@@ -132,26 +131,21 @@ $scriptString .= <<<script
132131
if (btnVatNumberElement) {
133132
this.btnVatNumberElement = btnVatNumberElement;
134133
if (countryElement.value.length) {
135-
this.btnValidateVatNumber(countryElement.value);
134+
this.renderValidateVatNumberButton(countryElement.value);
136135
}
137136
}
138137
},
139-
btnValidateVatNumber: function(countryCode)
138+
renderValidateVatNumberButton: function(countryCode)
140139
{
141140
var resultElement = document.getElementById("validation_result");
142-
var isEuCountry = false;
143-
const fruits = Object.values(this.euCountryList);
144-
145-
if ( fruits.includes(countryCode)) {
146-
isEuCountry = true;
147-
}
148-
if (isEuCountry) {
141+
if (this.euCountryList.includes(countryCode)) {
149142
this.btnVatNumberElement.classList.remove('disabled');
150143
if (resultElement) {
151144
resultElement.style.display = "block";
152145
resultElement.innerHTML = '';
153-
if ( resultElement.classList.contains('admin__field-error') )
154-
resultElement.classList.remove('admin__field-error');
146+
if (resultElement.classList.contains('admin__field-error')) {
147+
resultElement.classList.remove('admin__field-error');
148+
}
155149
}
156150
} else {
157151
this.btnVatNumberElement.classList.add('disabled');

0 commit comments

Comments
 (0)