55 */
66namespace Magento \Bundle \Helper \Catalog \Product ;
77
8+ use Magento \Catalog \Api \Data \ProductInterface ;
89use Magento \Catalog \Helper \Product \Configuration \ConfigurationInterface ;
910use Magento \Catalog \Model \Product \Configuration \Item \ItemInterface ;
1011use Magento \Framework \App \Helper \AbstractHelper ;
@@ -130,7 +131,6 @@ public function getSelectionFinalPrice(ItemInterface $item, \Magento\Catalog\Mod
130131 *
131132 * @param ItemInterface $item
132133 * @return array
133- * phpcs:disable Generic.Metrics.NestingLevel
134134 */
135135 public function getBundleOptions (ItemInterface $ item )
136136 {
@@ -166,29 +166,7 @@ public function getBundleOptions(ItemInterface $item)
166166 $ bundleSelections = $ bundleOption ->getSelections ();
167167
168168 foreach ($ bundleSelections as $ bundleSelection ) {
169- $ qty = $ this ->getSelectionQty ($ product , $ bundleSelection ->getSelectionId ()) * 1 ;
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- }
179- $ option ['value ' ][] = $ qty . ' x '
180- . $ this ->escaper ->escapeHtml ($ bundleSelection ->getName ())
181- . ' '
182- . $ this ->pricingHelper ->currency (
183- $ selectionFinalPrice
184- )
185- . ' '
186- . ($ displayBothPrices ? __ ('Excl. tax: ' ) . ' '
187- . $ this ->pricingHelper ->currency (
188- $ selectionFinalPriceExclTax
189- ) : '' );
190- $ option ['has_html ' ] = true ;
191- }
169+ $ option = $ this ->getOptionPriceHtml ($ item , $ bundleSelection , $ option );
192170 }
193171
194172 if ($ option ['value ' ]) {
@@ -201,7 +179,47 @@ public function getBundleOptions(ItemInterface $item)
201179
202180 return $ options ;
203181 }
204- //phpcs:enable Generic.Metrics.NestingLevel
182+
183+ /**
184+ * Get bundle options' prices
185+ *
186+ * @param ItemInterface $item
187+ * @param ProductInterface $bundleSelection
188+ * @param array $option
189+ * @return array
190+ */
191+ private function getOptionPriceHtml (ItemInterface $ item , ProductInterface $ bundleSelection , array $ option ): array
192+ {
193+ $ product = $ item ->getProduct ();
194+ $ qty = $ this ->getSelectionQty ($ item ->getProduct (), $ bundleSelection ->getSelectionId ()) * 1 ;
195+ if ($ qty ) {
196+ $ selectionPrice = $ this ->getSelectionFinalPrice ($ item , $ bundleSelection );
197+ $ selectionFinalPrice = $ this ->catalogHelper ->getTaxPrice ($ item ->getProduct (), $ selectionPrice );
198+
199+ $ displayBothPrices = $ this ->taxHelper ->displayBothPrices ();
200+ if ($ displayBothPrices ) {
201+ $ selectionFinalPrice =
202+ $ this ->catalogHelper
203+ ->getTaxPrice ($ product , $ selectionPrice , true );
204+ $ selectionFinalPriceExclTax =
205+ $ this ->catalogHelper
206+ ->getTaxPrice ($ product , $ selectionPrice , false );
207+ }
208+ $ option ['value ' ][] = $ qty . ' x '
209+ . $ this ->escaper ->escapeHtml ($ bundleSelection ->getName ())
210+ . ' '
211+ . $ this ->pricingHelper ->currency (
212+ $ selectionFinalPrice
213+ )
214+ . ' '
215+ . ($ displayBothPrices ? __ ('Excl. tax: ' ) . ' '
216+ . $ this ->pricingHelper ->currency (
217+ $ selectionFinalPriceExclTax
218+ ) : '' );
219+ $ option ['has_html ' ] = true ;
220+ }
221+ return $ option ;
222+ }
205223
206224 /**
207225 * Retrieves product options list
0 commit comments