Skip to content

Commit 0268086

Browse files
committed
ACP2E-45: Tiered pricing tax always shows including tax
- Fixed the solution part
1 parent bd07457 commit 0268086

File tree

4 files changed

+41
-56
lines changed

4 files changed

+41
-56
lines changed

app/code/Magento/Catalog/Pricing/Price/TierPrice.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class TierPrice extends AbstractPrice implements TierPriceInterface, BasePricePr
8787
*/
8888
public function __construct(
8989
Product $saleableItem,
90-
$quantity,
90+
$quantity,
9191
CalculatorInterface $calculator,
9292
PriceCurrencyInterface $priceCurrency,
9393
Session $customerSession,
@@ -176,10 +176,13 @@ public function getTierPriceList()
176176
function (&$priceData) {
177177
/* convert string value to float */
178178
$priceData['price_qty'] *= 1;
179-
if ($this->getConfigTaxDisplayType() === Config::DISPLAY_TYPE_BOTH) {
180-
$exclTaxPrice = $this->calculator->getAmount($priceData['price'], $this->product);
179+
$exclTaxPrice = $this->calculator->getAmount($priceData['price'], $this->product);
180+
if ($this->getConfigTaxDisplayType() === Config::DISPLAY_TYPE_EXCLUDING_TAX) {
181181
$priceData['excl_tax_price'] = $exclTaxPrice;
182182
}
183+
if ($this->getConfigTaxDisplayType() === Config::DISPLAY_TYPE_BOTH) {
184+
$priceData['incl_excl_tax_price'] = $exclTaxPrice;
185+
}
183186
$priceData['price'] = $this->applyAdjustment($priceData['price']);
184187
}
185188
);

app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php

Lines changed: 9 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
use Magento\Framework\Locale\Format;
1616
use Magento\Framework\Pricing\PriceCurrencyInterface;
1717
use Magento\Store\Model\Store;
18-
use Magento\Framework\App\Config\ScopeConfigInterface;
19-
use Magento\Tax\Model\Config;
2018

2119
/**
2220
* Confugurable product view type
@@ -27,8 +25,6 @@
2725
*/
2826
class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView
2927
{
30-
private const XML_PATH_TAX_DISPLAY_TYPE = 'tax/display/type';
31-
3228
/**
3329
* @var \Magento\Catalog\Helper\Product
3430
*/
@@ -82,11 +78,6 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView
8278
*/
8379
private $variationPrices;
8480

85-
/**
86-
* @var ScopeConfigInterface
87-
*/
88-
private $scopeConfig;
89-
9081
/**
9182
* @param \Magento\Catalog\Block\Product\Context $context
9283
* @param \Magento\Framework\Stdlib\ArrayUtils $arrayUtils
@@ -100,7 +91,6 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView
10091
* @param Format|null $localeFormat
10192
* @param Session|null $customerSession
10293
* @param \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Variations\Prices|null $variationPrices
103-
* @param ScopeConfigInterface|null $scopeConfig
10494
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
10595
*/
10696
public function __construct(
@@ -115,8 +105,7 @@ public function __construct(
115105
array $data = [],
116106
Format $localeFormat = null,
117107
Session $customerSession = null,
118-
\Magento\ConfigurableProduct\Model\Product\Type\Configurable\Variations\Prices $variationPrices = null,
119-
?ScopeConfigInterface $scopeConfig = null
108+
\Magento\ConfigurableProduct\Model\Product\Type\Configurable\Variations\Prices $variationPrices = null
120109
) {
121110
$this->priceCurrency = $priceCurrency;
122111
$this->helper = $helper;
@@ -129,7 +118,6 @@ public function __construct(
129118
$this->variationPrices = $variationPrices ?: ObjectManager::getInstance()->get(
130119
\Magento\ConfigurableProduct\Model\Product\Type\Configurable\Variations\Prices::class
131120
);
132-
$this->scopeConfig = $scopeConfig ?: ObjectManager::getInstance()->get(ScopeConfigInterface::class);
133121

134122
parent::__construct(
135123
$context,
@@ -344,38 +332,29 @@ private function getTierPricesByProduct(ProductInterface $product): array
344332
$tierPrices = [];
345333
$tierPriceModel = $product->getPriceInfo()->getPrice('tier_price');
346334
foreach ($tierPriceModel->getTierPriceList() as $tierPrice) {
347-
$price = $this->localeFormat->getNumber($tierPrice['price']->getValue());
348-
if ($this->getConfigTaxDisplayType() === Config::DISPLAY_TYPE_EXCLUDING_TAX) {
349-
$price = $this->localeFormat->getNumber($tierPrice['price']->getBaseAmount());
350-
}
351335
$tierPriceData = [
352336
'qty' => $this->localeFormat->getNumber($tierPrice['price_qty']),
353-
'price' => $price,
337+
'price' => $this->localeFormat->getNumber($tierPrice['price']->getValue()),
354338
'percentage' => $this->localeFormat->getNumber(
355339
$tierPriceModel->getSavePercent($tierPrice['price'])
356340
),
357341
];
358342

359343
if (isset($tierPrice['excl_tax_price'])) {
360-
$excludingTax = $tierPrice['excl_tax_price'];
361-
$tierPriceData['excl_tax_price'] = $this->localeFormat->getNumber($excludingTax->getBaseAmount());
344+
$exclTax = $tierPrice['excl_tax_price'];
345+
$tierPriceData['excl_tax_price'] = $this->localeFormat->getNumber($exclTax->getBaseAmount());
346+
}
347+
348+
if (isset($tierPrice['incl_excl_tax_price'])) {
349+
$inclExclTax = $tierPrice['incl_excl_tax_price'];
350+
$tierPriceData['incl_excl_tax_price'] = $this->localeFormat->getNumber($inclExclTax->getBaseAmount());
362351
}
363352
$tierPrices[] = $tierPriceData;
364353
}
365354

366355
return $tierPrices;
367356
}
368357

369-
/**
370-
* Returns config tax display type
371-
*
372-
* @return int
373-
*/
374-
private function getConfigTaxDisplayType(): int
375-
{
376-
return (int) $this->scopeConfig->getValue(self::XML_PATH_TAX_DISPLAY_TYPE);
377-
}
378-
379358
/**
380359
* Replace ',' on '.' for js
381360
*

app/code/Magento/ConfigurableProduct/composer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
"magento/module-media-storage": "*",
1717
"magento/module-quote": "*",
1818
"magento/module-store": "*",
19-
"magento/module-ui": "*",
20-
"magento/module-tax": "*"
19+
"magento/module-ui": "*"
2120
},
2221
"suggest": {
2322
"magento/module-msrp": "*",

app/code/Magento/ConfigurableProduct/view/base/templates/product/price/tier_price.phtml

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,34 +7,38 @@
77
?>
88
<script type="text/x-magento-template" id="tier-prices-template">
99
<ul class="prices-tier items">
10-
<% var exclPrice = ' <span class="price-wrapper price-excluding-tax"'
11-
+ 'data-label="<?= $block->escapeHtml(__('Excl. Tax')) ?>">'
12-
+ '<span class="price">&nbsp;%1</span>'
13-
+ '</span>'
10+
<% var inclExclPrice = ' <span class="price-wrapper price-excluding-tax"'
11+
+ 'data-label="<?= $block->escapeHtml(__('Excl. Tax')) ?>">'
12+
+ '<span class="price">&nbsp;%1</span>'
13+
+ '</span>'
1414
%>
1515

1616
<% _.each(tierPrices, function(item, key) { %>
17-
<% var itemExclPrice = item.hasOwnProperty('excl_tax_price')
18-
? exclPrice.replace('%1', priceUtils.formatPrice(item['excl_tax_price'], currencyFormat))
19-
: ''
20-
%>
17+
<% var itemInclExclPrice = item.hasOwnProperty('incl_excl_tax_price')
18+
? inclExclPrice.replace('%1', priceUtils.formatPrice(item['incl_excl_tax_price'], currencyFormat))
19+
: ''
20+
%>
21+
<% var price = item.hasOwnProperty('excl_tax_price')
22+
? priceUtils.formatPrice(item['excl_tax_price'], currencyFormat)
23+
: priceUtils.formatPrice(item.price, currencyFormat)
24+
%>
2125

22-
<% var priceStr = '<span class="price-container price-tier_price">'
26+
<% var priceStr = '<span class="price-container price-tier_price">'
2327
+ '<span data-price-amount="' + priceUtils.formatPrice(item.price, currencyFormat) + '"'
2428
+ ' data-price-type=""' + ' class="price-wrapper price-including-tax">'
25-
+ '<span class="price">' + priceUtils.formatPrice(item.price, currencyFormat) + '</span>'
26-
+ '</span>' + itemExclPrice + '</span>';
29+
+ '<span class="price">' + price + '</span>'
30+
+ '</span>' + itemInclExclPrice + '</span>';
31+
%>
32+
<li class="item">
33+
<%= '<?= $block->escapeHtml(__('Buy %1 for %2 each and', '%1', '%2')) ?>'
34+
.replace('%1', item.qty)
35+
.replace('%2', priceStr)
2736
%>
28-
<li class="item">
29-
<%= '<?= $block->escapeHtml(__('Buy %1 for %2 each and', '%1', '%2')) ?>'
30-
.replace('%1', item.qty)
31-
.replace('%2', priceStr)
32-
%>
33-
<strong class="benefit">
34-
<?= $block->escapeHtml(__('save')) ?><span
35-
class="percent tier-<%= key %>">&nbsp;<%= item.percentage %></span>%
36-
</strong>
37-
</li>
37+
<strong class="benefit">
38+
<?= $block->escapeHtml(__('save')) ?><span
39+
class="percent tier-<%= key %>">&nbsp;<%= item.percentage %></span>%
40+
</strong>
41+
</li>
3842
<% }); %>
3943
</ul>
4044
</script>

0 commit comments

Comments
 (0)