@@ -48,28 +48,36 @@ class Configuration extends AbstractHelper implements ConfigurationInterface
48
48
*/
49
49
private $ catalogHelper ;
50
50
51
+ /**
52
+ * @var \Magento\Tax\Helper\Data|mixed
53
+ */
54
+ private $ taxHelper ;
55
+
51
56
/**
52
57
* @param \Magento\Framework\App\Helper\Context $context
53
58
* @param \Magento\Catalog\Helper\Product\Configuration $productConfiguration
54
59
* @param \Magento\Framework\Pricing\Helper\Data $pricingHelper
55
60
* @param \Magento\Framework\Escaper $escaper
56
61
* @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
57
62
* @param \Magento\Catalog\Helper\Data|null $catalogHelper
63
+ * @param \Magento\Tax\Helper\Data|null $taxHelper
58
64
*/
59
65
public function __construct (
60
66
\Magento \Framework \App \Helper \Context $ context ,
61
67
\Magento \Catalog \Helper \Product \Configuration $ productConfiguration ,
62
68
\Magento \Framework \Pricing \Helper \Data $ pricingHelper ,
63
69
\Magento \Framework \Escaper $ escaper ,
64
70
\Magento \Framework \Serialize \Serializer \Json $ serializer = null ,
65
- \Magento \Catalog \Helper \Data $ catalogHelper = null
71
+ \Magento \Catalog \Helper \Data $ catalogHelper = null ,
72
+ \Magento \Tax \Helper \Data $ taxHelper = null
66
73
) {
67
74
$ this ->productConfiguration = $ productConfiguration ;
68
75
$ this ->pricingHelper = $ pricingHelper ;
69
76
$ this ->escaper = $ escaper ;
70
77
$ this ->serializer = $ serializer ?: \Magento \Framework \App \ObjectManager::getInstance ()
71
78
->get (\Magento \Framework \Serialize \Serializer \Json::class);
72
79
$ this ->catalogHelper = $ catalogHelper ?? ObjectManager::getInstance ()->get (\Magento \Catalog \Helper \Data::class);
80
+ $ this ->taxHelper = $ taxHelper ?? ObjectManager::getInstance ()->get (\Magento \Tax \Helper \Data::class);
73
81
parent ::__construct ($ context );
74
82
}
75
83
@@ -104,16 +112,14 @@ public function getSelectionFinalPrice(ItemInterface $item, \Magento\Catalog\Mod
104
112
/** @var \Magento\Bundle\Model\Product\Price $price */
105
113
$ price = $ product ->getPriceModel ();
106
114
107
- $ selectionPrice = $ price ->getSelectionFinalTotalPrice (
115
+ return $ price ->getSelectionFinalTotalPrice (
108
116
$ product ,
109
117
$ selectionProduct ,
110
118
$ item ->getQty (),
111
119
$ this ->getSelectionQty ($ product , $ selectionProduct ->getSelectionId ()),
112
120
false ,
113
121
true
114
122
);
115
-
116
- return $ this ->catalogHelper ->getTaxPrice ($ selectionProduct , $ selectionPrice );
117
123
}
118
124
119
125
/**
@@ -162,12 +168,25 @@ public function getBundleOptions(ItemInterface $item)
162
168
foreach ($ bundleSelections as $ bundleSelection ) {
163
169
$ qty = $ this ->getSelectionQty ($ product , $ bundleSelection ->getSelectionId ()) * 1 ;
164
170
if ($ qty ) {
171
+ $ selectionPrice = $ this ->getSelectionFinalPrice ($ item , $ bundleSelection );
172
+ $ selectionFinalPrice = $ this ->catalogHelper ->getTaxPrice ($ item , $ selectionPrice );
173
+
174
+ $ displayBothPrices = $ this ->taxHelper ->displayBothPrices ();
175
+ if ($ displayBothPrices ) {
176
+ $ selectionFinalPrice = $ this ->catalogHelper ->getTaxPrice ($ item , $ selectionPrice , true );
177
+ $ selectionFinalPriceExclTax = $ this ->catalogHelper ->getTaxPrice ($ item , $ selectionPrice , false );
178
+ }
165
179
$ option ['value ' ][] = $ qty . ' x '
166
180
. $ this ->escaper ->escapeHtml ($ bundleSelection ->getName ())
167
181
. ' '
168
182
. $ this ->pricingHelper ->currency (
169
- $ this ->getSelectionFinalPrice ($ item , $ bundleSelection )
170
- );
183
+ $ selectionFinalPrice
184
+ )
185
+ . ' '
186
+ . ($ displayBothPrices ? __ ('Excl. tax: ' ) . ' '
187
+ . $ this ->pricingHelper ->currency (
188
+ $ selectionFinalPriceExclTax
189
+ ) : '' );
171
190
$ option ['has_html ' ] = true ;
172
191
}
173
192
}
0 commit comments