@@ -48,28 +48,36 @@ class Configuration extends AbstractHelper implements ConfigurationInterface
4848 */
4949 private $ catalogHelper ;
5050
51+ /**
52+ * @var \Magento\Tax\Helper\Data|mixed
53+ */
54+ private $ taxHelper ;
55+
5156 /**
5257 * @param \Magento\Framework\App\Helper\Context $context
5358 * @param \Magento\Catalog\Helper\Product\Configuration $productConfiguration
5459 * @param \Magento\Framework\Pricing\Helper\Data $pricingHelper
5560 * @param \Magento\Framework\Escaper $escaper
5661 * @param \Magento\Framework\Serialize\Serializer\Json|null $serializer
5762 * @param \Magento\Catalog\Helper\Data|null $catalogHelper
63+ * @param \Magento\Tax\Helper\Data|null $taxHelper
5864 */
5965 public function __construct (
6066 \Magento \Framework \App \Helper \Context $ context ,
6167 \Magento \Catalog \Helper \Product \Configuration $ productConfiguration ,
6268 \Magento \Framework \Pricing \Helper \Data $ pricingHelper ,
6369 \Magento \Framework \Escaper $ escaper ,
6470 \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
6673 ) {
6774 $ this ->productConfiguration = $ productConfiguration ;
6875 $ this ->pricingHelper = $ pricingHelper ;
6976 $ this ->escaper = $ escaper ;
7077 $ this ->serializer = $ serializer ?: \Magento \Framework \App \ObjectManager::getInstance ()
7178 ->get (\Magento \Framework \Serialize \Serializer \Json::class);
7279 $ this ->catalogHelper = $ catalogHelper ?? ObjectManager::getInstance ()->get (\Magento \Catalog \Helper \Data::class);
80+ $ this ->taxHelper = $ taxHelper ?? ObjectManager::getInstance ()->get (\Magento \Tax \Helper \Data::class);
7381 parent ::__construct ($ context );
7482 }
7583
@@ -104,16 +112,14 @@ public function getSelectionFinalPrice(ItemInterface $item, \Magento\Catalog\Mod
104112 /** @var \Magento\Bundle\Model\Product\Price $price */
105113 $ price = $ product ->getPriceModel ();
106114
107- $ selectionPrice = $ price ->getSelectionFinalTotalPrice (
115+ return $ price ->getSelectionFinalTotalPrice (
108116 $ product ,
109117 $ selectionProduct ,
110118 $ item ->getQty (),
111119 $ this ->getSelectionQty ($ product , $ selectionProduct ->getSelectionId ()),
112120 false ,
113121 true
114122 );
115-
116- return $ this ->catalogHelper ->getTaxPrice ($ selectionProduct , $ selectionPrice );
117123 }
118124
119125 /**
@@ -162,12 +168,25 @@ public function getBundleOptions(ItemInterface $item)
162168 foreach ($ bundleSelections as $ bundleSelection ) {
163169 $ qty = $ this ->getSelectionQty ($ product , $ bundleSelection ->getSelectionId ()) * 1 ;
164170 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+ }
165179 $ option ['value ' ][] = $ qty . ' x '
166180 . $ this ->escaper ->escapeHtml ($ bundleSelection ->getName ())
167181 . ' '
168182 . $ this ->pricingHelper ->currency (
169- $ this ->getSelectionFinalPrice ($ item , $ bundleSelection )
170- );
183+ $ selectionFinalPrice
184+ )
185+ . ' '
186+ . ($ displayBothPrices ? __ ('Excl. tax: ' ) . ' '
187+ . $ this ->pricingHelper ->currency (
188+ $ selectionFinalPriceExclTax
189+ ) : '' );
171190 $ option ['has_html ' ] = true ;
172191 }
173192 }
0 commit comments