diff --git a/app/code/Magento/Catalog/Block/Product/View.php b/app/code/Magento/Catalog/Block/Product/View.php index e24b3d881bdf8..7524ceb23d931 100644 --- a/app/code/Magento/Catalog/Block/Product/View.php +++ b/app/code/Magento/Catalog/Block/Product/View.php @@ -183,8 +183,19 @@ public function getJsonConfig() foreach ($tierPricesList as $tierPrice) { $tierPriceData = [ 'qty' => $tierPrice['price_qty'], - 'price' => $tierPrice['website_price'], + 'price' => $tierPrice['website_price'] ]; + + if ( + isset($tierPrice['excl_tax_price']) && + $tierPrice['excl_tax_price'] instanceof \Magento\Framework\Pricing\Amount\AmountInterface + ) { + $tierPriceData['excl_tax_price'] = + $this->priceCurrency->convertAndRound( + $tierPrice['excl_tax_price']->getValue(['tax']) + ); + } + $tierPrices[] = $tierPriceData; } diff --git a/app/code/Magento/Catalog/Pricing/Price/TierPrice.php b/app/code/Magento/Catalog/Pricing/Price/TierPrice.php index aee0ab643547a..5c9d8f5cba666 100644 --- a/app/code/Magento/Catalog/Pricing/Price/TierPrice.php +++ b/app/code/Magento/Catalog/Pricing/Price/TierPrice.php @@ -18,6 +18,7 @@ use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Framework\Pricing\PriceInfoInterface; use Magento\Customer\Model\Group\RetrieverInterface as CustomerGroupRetrieverInterface; +use Magento\Store\Model\ScopeInterface; use Magento\Tax\Model\Config; /** @@ -176,7 +177,7 @@ public function getTierPriceList() function (&$priceData) { /* convert string value to float */ $priceData['price_qty'] *= 1; - if ($this->getConfigTaxDisplayType() === Config::DISPLAY_TYPE_BOTH) { + if ($this->getConfigTaxDisplayType() !== Config::DISPLAY_TYPE_INCLUDING_TAX) { $exclTaxPrice = $this->calculator->getAmount($priceData['price'], $this->product); $priceData['excl_tax_price'] = $exclTaxPrice; } @@ -195,7 +196,7 @@ function (&$priceData) { */ private function getConfigTaxDisplayType(): int { - return (int) $this->scopeConfig->getValue(self::XML_PATH_TAX_DISPLAY_TYPE); + return (int) $this->scopeConfig->getValue(self::XML_PATH_TAX_DISPLAY_TYPE, ScopeInterface::SCOPE_WEBSITE); } /** diff --git a/app/code/Magento/Catalog/view/base/web/js/price-box.js b/app/code/Magento/Catalog/view/base/web/js/price-box.js index 7028e42cc4597..aa54ebc00cdc3 100644 --- a/app/code/Magento/Catalog/view/base/web/js/price-box.js +++ b/app/code/Magento/Catalog/view/base/web/js/price-box.js @@ -224,23 +224,31 @@ define([ */ updateProductTierPrice: function updateProductTierPrice() { var productQty = $(this.qtyInfo).val(), - originalPrice = this.options.prices.finalPrice.amount, tierPrice, - prices, + tierPriceExcl, i; for (i = 0; i < this.options.priceConfig.tierPrices.length; i++) { if (productQty >= this.options.priceConfig.tierPrices[i].qty) { tierPrice = this.options.priceConfig.tierPrices[i].price; + tierPriceExcl = this.options.priceConfig.tierPrices[i].excl_tax_price; } } - prices = { - 'prices': { - 'finalPrice': { - 'amount': tierPrice - originalPrice - } - } + + var prices = { + 'prices': {} }; + + _.each(this.options.prices, function (priceType, index) { + var tierPriceType = index === 'basePrice' && tierPriceExcl ? + tierPriceExcl : + tierPrice; + + prices['prices'][index] = { + amount: tierPriceType - priceType.amount + }; + }); + this.updatePrice(prices); } });