15
15
use Magento \Framework \Locale \Format ;
16
16
use Magento \Framework \Pricing \PriceCurrencyInterface ;
17
17
use Magento \Store \Model \Store ;
18
+ use Magento \Framework \App \Config \ScopeConfigInterface ;
19
+ use Magento \Tax \Model \Config ;
18
20
19
21
/**
20
22
* Confugurable product view type
25
27
*/
26
28
class Configurable extends \Magento \Catalog \Block \Product \View \AbstractView
27
29
{
30
+ private const XML_PATH_TAX_DISPLAY_TYPE = 'tax/display/type ' ;
31
+
28
32
/**
29
33
* @var \Magento\Catalog\Helper\Product
30
34
*/
@@ -78,6 +82,11 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView
78
82
*/
79
83
private $ variationPrices ;
80
84
85
+ /**
86
+ * @var ScopeConfigInterface
87
+ */
88
+ private $ scopeConfig ;
89
+
81
90
/**
82
91
* @param \Magento\Catalog\Block\Product\Context $context
83
92
* @param \Magento\Framework\Stdlib\ArrayUtils $arrayUtils
@@ -91,6 +100,7 @@ class Configurable extends \Magento\Catalog\Block\Product\View\AbstractView
91
100
* @param Format|null $localeFormat
92
101
* @param Session|null $customerSession
93
102
* @param \Magento\ConfigurableProduct\Model\Product\Type\Configurable\Variations\Prices|null $variationPrices
103
+ * @param ScopeConfigInterface|null $scopeConfig
94
104
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
95
105
*/
96
106
public function __construct (
@@ -105,7 +115,8 @@ public function __construct(
105
115
array $ data = [],
106
116
Format $ localeFormat = null ,
107
117
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
109
120
) {
110
121
$ this ->priceCurrency = $ priceCurrency ;
111
122
$ this ->helper = $ helper ;
@@ -118,6 +129,7 @@ public function __construct(
118
129
$ this ->variationPrices = $ variationPrices ?: ObjectManager::getInstance ()->get (
119
130
\Magento \ConfigurableProduct \Model \Product \Type \Configurable \Variations \Prices::class
120
131
);
132
+ $ this ->scopeConfig = $ scopeConfig ?: ObjectManager::getInstance ()->get (ScopeConfigInterface::class);
121
133
122
134
parent ::__construct (
123
135
$ context ,
@@ -332,9 +344,13 @@ private function getTierPricesByProduct(ProductInterface $product): array
332
344
$ tierPrices = [];
333
345
$ tierPriceModel = $ product ->getPriceInfo ()->getPrice ('tier_price ' );
334
346
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
+ }
335
351
$ tierPriceData = [
336
352
'qty ' => $ this ->localeFormat ->getNumber ($ tierPrice ['price_qty ' ]),
337
- 'price ' => $ this -> localeFormat -> getNumber ( $ tierPrice [ ' price ' ]-> getValue ()) ,
353
+ 'price ' => $ price ,
338
354
'percentage ' => $ this ->localeFormat ->getNumber (
339
355
$ tierPriceModel ->getSavePercent ($ tierPrice ['price ' ])
340
356
),
@@ -350,6 +366,16 @@ private function getTierPricesByProduct(ProductInterface $product): array
350
366
return $ tierPrices ;
351
367
}
352
368
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
+
353
379
/**
354
380
* Replace ',' on '.' for js
355
381
*
0 commit comments