Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,11 @@ define([
index = 1,
allowedProducts,
i,
j;
j,
basePrice = parseFloat(this.options.spConfig.prices.basePrice.amount),
optionFinalPrice,
optionPriceDiff,
optionPrices = this.options.spConfig.optionPrices;

this._clearSelect(element);
element.options[0] = new Option('', '');
Expand All @@ -374,6 +378,7 @@ define([
if (options) {
for (i = 0; i < options.length; i++) {
allowedProducts = [];
optionPriceDiff = 0;

/* eslint-disable max-depth */
if (prevConfig) {
Expand All @@ -387,14 +392,28 @@ define([
}
} else {
allowedProducts = options[i].products.slice(0);

if (typeof allowedProducts[0] !== 'undefined' &&
typeof optionPrices[allowedProducts[0]] !== 'undefined') {

optionFinalPrice = parseFloat(optionPrices[allowedProducts[0]].finalPrice.amount);
optionPriceDiff = optionFinalPrice - basePrice;

if (optionPriceDiff !== 0) {
options[i].label = options[i].label + ' ' + priceUtils.formatPrice(
optionPriceDiff,
this.options.priceFormat,
true);
}
}
}

if (allowedProducts.length > 0) {
options[i].allowedProducts = allowedProducts;
element.options[index] = new Option(this._getOptionLabel(options[i]), options[i].id);

if (typeof options[i].price !== 'undefined') {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this functionality is never used. Also it has a bug with attribute name (uses prices instead price)

element.options[index].setAttribute('price', options[i].prices);
element.options[index].setAttribute('price', options[i].price);
}

element.options[index].config = options[i];
Expand Down