Skip to content

Commit 2b6090b

Browse files
committed
ACP2E-291: Excl.Tax Tier Price issue on QTY Change
1 parent 86b5ca0 commit 2b6090b

File tree

1 file changed

+28
-23
lines changed

1 file changed

+28
-23
lines changed

app/code/Magento/Catalog/view/base/web/js/price-box.js

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -223,37 +223,42 @@ define([
223223
* Updates product final and base price according to tier prices
224224
*/
225225
updateProductTierPrice: function updateProductTierPrice() {
226-
var productQty = $(this.qtyInfo).val(),
227-
tierPrice,
228-
prices = {'prices': {}},
229-
i;
226+
var originalPrice,
227+
prices = {'prices': {}};
230228

231229
if (this.options.prices.finalPrice) {
232-
var originalPrice = this.options.prices.finalPrice.amount;
233-
234-
for (i = 0; i < this.options.priceConfig.tierPrices.length; i++) {
235-
if (productQty >= this.options.priceConfig.tierPrices[i].qty) {
236-
tierPrice = this.options.priceConfig.tierPrices[i].price;
237-
}
238-
}
239-
prices.prices.finalPrice = {'amount': tierPrice - originalPrice};
230+
originalPrice = this.options.prices.finalPrice.amount;
231+
prices.prices.finalPrice = {'amount': this.getPrice('price') - originalPrice};
240232
}
241233

242234
if (this.options.prices.basePrice) {
243-
var originalBasePrice = this.options.prices.basePrice.amount,
244-
tierBasePrice,
245-
tierPriceItem;
246-
247-
for (i = 0; i < this.options.priceConfig.tierPrices.length; i++) {
248-
tierPriceItem = this.options.priceConfig.tierPrices[i];
249-
if (productQty >= tierPriceItem.qty && tierPriceItem.basePrice) {
250-
tierBasePrice = tierPriceItem.basePrice;
251-
}
252-
}
253-
prices.prices.basePrice = {'amount': tierBasePrice - originalBasePrice};
235+
originalPrice = this.options.prices.basePrice.amount;
236+
prices.prices.basePrice = {'amount': this.getPrice('basePrice') - originalPrice};
254237
}
255238

256239
this.updatePrice(prices);
240+
},
241+
242+
/**
243+
* Returns price.
244+
*
245+
* @param {String} priceKey
246+
* @returns {Number}
247+
*/
248+
getPrice: function (priceKey) {
249+
var productQty = $(this.qtyInfo).val(),
250+
result,
251+
tierPriceItem,
252+
i;
253+
254+
for (i = 0; i < this.options.priceConfig.tierPrices.length; i++) {
255+
tierPriceItem = this.options.priceConfig.tierPrices[i];
256+
if (productQty >= tierPriceItem.qty && tierPriceItem[priceKey]) {
257+
result = tierPriceItem[priceKey];
258+
}
259+
}
260+
261+
return result;
257262
}
258263
});
259264

0 commit comments

Comments
 (0)