Skip to content

Commit d2887ed

Browse files
committed
ACP2E-45: Tiered pricing tax always shows including tax
- Fixed the bug.
1 parent 72239c5 commit d2887ed

File tree

1 file changed

+28
-2
lines changed

1 file changed

+28
-2
lines changed

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

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
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;
1820

1921
/**
2022
* Confugurable product view type
@@ -25,6 +27,8 @@
2527
*/
2628
class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView
2729
{
30+
private const XML_PATH_TAX_DISPLAY_TYPE = 'tax/display/type';
31+
2832
/**
2933
* @var \Magento\Catalog\Helper\Product
3034
*/
@@ -78,6 +82,11 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView
7882
*/
7983
private $variationPrices;
8084

85+
/**
86+
* @var ScopeConfigInterface
87+
*/
88+
private $scopeConfig;
89+
8190
/**
8291
* @param \Magento\Catalog\Block\Product\Context $context
8392
* @param \Magento\Framework\Stdlib\ArrayUtils $arrayUtils
@@ -91,6 +100,7 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView
91100
* @param Format|null $localeFormat
92101
* @param Session|null $customerSession
93102
* @param \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Variations\Prices|null $variationPrices
103+
* @param ScopeConfigInterface|null $scopeConfig
94104
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
95105
*/
96106
public function __construct(
@@ -105,7 +115,8 @@ public function __construct(
105115
array $data = [],
106116
Format $localeFormat = null,
107117
Session $customerSession = null,
108-
\Magento\ConfigurableProduct\Model\Product\Type\Configurable\Variations\Prices $variationPrices = null
118+
\Magento\ConfigurableProduct\Model\Product\Type\Configurable\Variations\Prices $variationPrices = null,
119+
?ScopeConfigInterface $scopeConfig = null
109120
) {
110121
$this->priceCurrency = $priceCurrency;
111122
$this->helper = $helper;
@@ -118,6 +129,7 @@ public function __construct(
118129
$this->variationPrices = $variationPrices ?: ObjectManager::getInstance()->get(
119130
\Magento\ConfigurableProduct\Model\Product\Type\Configurable\Variations\Prices::class
120131
);
132+
$this->scopeConfig = $scopeConfig ?: ObjectManager::getInstance()->get(ScopeConfigInterface::class);
121133

122134
parent::__construct(
123135
$context,
@@ -332,9 +344,13 @@ private function getTierPricesByProduct(ProductInterface $product): array
332344
$tierPrices = [];
333345
$tierPriceModel = $product->getPriceInfo()->getPrice('tier_price');
334346
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+
}
335351
$tierPriceData = [
336352
'qty' => $this->localeFormat->getNumber($tierPrice['price_qty']),
337-
'price' => $this->localeFormat->getNumber($tierPrice['price']->getValue()),
353+
'price' => $price,
338354
'percentage' => $this->localeFormat->getNumber(
339355
$tierPriceModel->getSavePercent($tierPrice['price'])
340356
),
@@ -350,6 +366,16 @@ private function getTierPricesByProduct(ProductInterface $product): array
350366
return $tierPrices;
351367
}
352368

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+
353379
/**
354380
* Replace ',' on '.' for js
355381
*

0 commit comments

Comments
 (0)