@@ -260,20 +260,7 @@ public function getOptionPrice($optionValue, $basePrice)
260
260
foreach (explode (', ' , $ optionValue ) as $ value ) {
261
261
$ _result = $ option ->getValueById ($ value );
262
262
if ($ _result ) {
263
- $ catalogPriceValue = $ this ->calculateCustomOptionCatalogRule ->execute (
264
- $ option ->getProduct (),
265
- (float )$ _result ->getPrice (),
266
- $ _result ->getPriceType () === Value::TYPE_PERCENT
267
- );
268
- if ($ catalogPriceValue !==null ) {
269
- $ result += $ catalogPriceValue ;
270
- } else {
271
- $ result += $ this ->_getChargeableOptionPrice (
272
- $ _result ->getPrice (),
273
- $ _result ->getPriceType () == 'percent ' ,
274
- $ basePrice
275
- );
276
- }
263
+ $ result += $ this ->getCalculatedOptionValue ($ option , $ _result , $ basePrice );
277
264
} else {
278
265
if ($ this ->getListener ()) {
279
266
$ this ->getListener ()->setHasError (true )->setMessage ($ this ->_getWrongConfigurationMessage ());
@@ -359,4 +346,31 @@ protected function _isSingleSelection()
359
346
{
360
347
return in_array ($ this ->getOption ()->getType (), $ this ->singleSelectionTypes , true );
361
348
}
349
+
350
+ /**
351
+ * Returns calculated price of option
352
+ *
353
+ * @param \Magento\Catalog\Model\Product\Option $option
354
+ * @param \Magento\Catalog\Model\Product\Option\Value $result
355
+ * @param float $basePrice
356
+ * @return float|null
357
+ */
358
+ protected function getCalculatedOptionValue ($ option , $ result , $ basePrice )
359
+ {
360
+ $ catalogPriceValue = $ this ->calculateCustomOptionCatalogRule ->execute (
361
+ $ option ->getProduct (),
362
+ (float )$ result ->getPrice (),
363
+ $ result ->getPriceType () === Value::TYPE_PERCENT
364
+ );
365
+ if ($ catalogPriceValue !==null ) {
366
+ $ optionCalculatedValue = $ catalogPriceValue ;
367
+ } else {
368
+ $ optionCalculatedValue = $ this ->_getChargeableOptionPrice (
369
+ $ result ->getPrice (),
370
+ $ result ->getPriceType () == 'percent ' ,
371
+ $ basePrice
372
+ );
373
+ }
374
+ return $ optionCalculatedValue ;
375
+ }
362
376
}
0 commit comments