Skip to content

Commit 2b7691c

Browse files
committed
MC-16221: Cannot save Shipping Methods page because in UPS method have required fields
1 parent dc94dc9 commit 2b7691c

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

app/code/Magento/Ups/view/adminhtml/templates/system/shipping/carrier_config.phtml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ require(["prototype"], function(){
6767
upsXml.prototype = {
6868
initialize: function()
6969
{
70+
this.carriersUpsActiveId = 'carriers_ups_active';
7071
this.carriersUpsTypeId = 'carriers_ups_type';
7172
if (!$(this.carriersUpsTypeId)) {
7273
return;
@@ -94,6 +95,7 @@ require(["prototype"], function(){
9495

9596
this.setFormValues();
9697
Event.observe($(this.carriersUpsTypeId), 'change', this.setFormValues.bind(this));
98+
Event.observe($(this.carriersUpsActiveId), 'change', this.setFormValues.bind(this));
9799
},
98100
updateAllowedMethods: function(originShipmentTitle)
99101
{
@@ -121,7 +123,7 @@ require(["prototype"], function(){
121123
freeMethod.insert(option);
122124

123125
option = new Element('option', {value:code}).update(originShipment[code]);
124-
if (this.storedUpsType == 'UPS_XML') {
126+
if (this.storedUpsType == 'UPS') {
125127
if (originShipmentTitle != 'default' || inArray(this.storedAllowedMethods, code)) {
126128
option.selected = true;
127129
}
@@ -143,12 +145,13 @@ require(["prototype"], function(){
143145
setFormValues: function()
144146
{
145147
var a;
146-
if ($F(this.carriersUpsTypeId) == 'UPS_XML') {
148+
if ($F(this.carriersUpsTypeId) == 'UPS') {
147149
for (a = 0; a < this.checkingUpsXmlId.length; a++) {
148150
$(this.checkingUpsXmlId[a]).removeClassName('required-entry');
149151
}
150152
for (a = 0; a < this.checkingUpsId.length; a++) {
151-
$(this.checkingUpsXmlId[a]).addClassName('required-entry');
153+
$(this.checkingUpsId[a]).addClassName('required-entry');
154+
this.changeFieldsDisabledState(this.checkingUpsId, a);
152155
}
153156
Event.stopObserving($('carriers_ups_origin_shipment'), 'change', this.changeOriginShipment.bind(this));
154157
showRowArrayElements(this.onlyUpsElements);
@@ -157,9 +160,10 @@ require(["prototype"], function(){
157160
} else {
158161
for (a = 0; a < this.checkingUpsXmlId.length; a++) {
159162
$(this.checkingUpsXmlId[a]).addClassName('required-entry');
163+
this.changeFieldsDisabledState(this.checkingUpsXmlId, a);
160164
}
161165
for (a = 0; a < this.checkingUpsId.length; a++) {
162-
$(this.checkingUpsXmlId[a]).removeClassName('required-entry');
166+
$(this.checkingUpsId[a]).removeClassName('required-entry');
163167
}
164168
Event.observe($('carriers_ups_origin_shipment'), 'change', this.changeOriginShipment.bind(this));
165169
showRowArrayElements(this.onlyUpsXmlElements);
@@ -171,6 +175,16 @@ require(["prototype"], function(){
171175
{
172176
this.originShipmentTitle = key ? key : $F('carriers_ups_origin_shipment');
173177
this.updateAllowedMethods(this.originShipmentTitle);
178+
},
179+
changeFieldsDisabledState: function (fields, key) {
180+
$(fields[key]).disabled = $F(this.carriersUpsActiveId) !== '1'
181+
|| $(fields[key] + '_inherit') !== null
182+
&& $F(fields[key] + '_inherit') === '1';
183+
184+
if ($(fields[key]).next() !== undefined) {
185+
$(fields[key]).removeClassName('mage-error').next().remove();
186+
$(fields[key]).removeAttribute('style');
187+
}
174188
}
175189
};
176190
xml = new upsXml();

0 commit comments

Comments
 (0)