Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue where dynamic JS price updates for tier prices wouldn't u… #34983

Open
wants to merge 2 commits into
base: 2.4-develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
13 changes: 12 additions & 1 deletion app/code/Magento/Catalog/Block/Product/View.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
5 changes: 3 additions & 2 deletions app/code/Magento/Catalog/Pricing/Price/TierPrice.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

/**
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
}

/**
Expand Down
24 changes: 16 additions & 8 deletions app/code/Magento/Catalog/view/base/web/js/price-box.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
});
Expand Down