Skip to content

Commit 17d723a

Browse files
committed
ACP2E-1784: covered all type of options for bundle: checkbox, radio, select and multiple select.
1 parent 3c9e898 commit 17d723a

File tree

1 file changed

+30
-7
lines changed

1 file changed

+30
-7
lines changed

app/code/Magento/Bundle/view/base/web/js/price-bundle.js

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,10 @@ define([
4444
options = $(this.options.productBundleSelector, form),
4545
qty = $(this.options.qtyFieldSelector, form);
4646

47-
options.trigger('change');
48-
4947
// Override defaults with URL query parameters and/or inputs values
5048
this._overrideDefaults();
5149

50+
options.trigger('change');
5251
qty.trigger('change');
5352
},
5453

@@ -90,21 +89,45 @@ define([
9089
var queryParams = $.parseQuery({
9190
query: queryString
9291
}),
92+
selectedValues = [],
9393
form = this.element,
9494
options = $(this.options.productBundleSelector, form),
9595
qtys = $(this.options.qtyFieldSelector, form);
9696

9797
$.each(queryParams, $.proxy(function (key, value) {
98-
options.each(function (index, option) {
99-
if (option.name === key) {
100-
$(option).val(value);
101-
}
102-
});
10398
qtys.each(function (index, qty) {
10499
if (qty.name === key) {
105100
$(qty).val(value);
106101
}
107102
});
103+
options.each(function (index, option) {
104+
let optionType = $(option).prop('type');
105+
106+
if (option.name === key ||
107+
optionType === 'select-multiple'
108+
&& key.indexOf(option.name.substr(0, option.name.length - 2)) !== false
109+
) {
110+
111+
switch (optionType) {
112+
case 'radio':
113+
$(option).val() === value ? $(option).prop('checked', true) : '';
114+
break;
115+
case 'checkbox':
116+
$(option).prop('checked', true);
117+
break;
118+
case 'hidden':
119+
case 'select-one':
120+
$(option).val(value);
121+
break;
122+
case 'select-multiple':
123+
selectedValues.push(value);
124+
break;
125+
}
126+
if (optionType === 'select-multiple' && selectedValues.length) {
127+
$(option).val(selectedValues);
128+
}
129+
}
130+
});
108131
}, this));
109132
},
110133

0 commit comments

Comments
 (0)