Skip to content

Commit bb78ad8

Browse files
committed
MC-35065: Catalog pricerules are not working with custom options as expected in Magento 2.3.0 product details page
1 parent 263ae67 commit bb78ad8

File tree

1 file changed

+28
-14
lines changed
  • app/code/Magento/Catalog/Model/Product/Option/Type

1 file changed

+28
-14
lines changed

app/code/Magento/Catalog/Model/Product/Option/Type/Select.php

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -260,20 +260,7 @@ public function getOptionPrice($optionValue, $basePrice)
260260
foreach (explode(',', $optionValue) as $value) {
261261
$_result = $option->getValueById($value);
262262
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);
277264
} else {
278265
if ($this->getListener()) {
279266
$this->getListener()->setHasError(true)->setMessage($this->_getWrongConfigurationMessage());
@@ -359,4 +346,31 @@ protected function _isSingleSelection()
359346
{
360347
return in_array($this->getOption()->getType(), $this->singleSelectionTypes, true);
361348
}
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+
}
362376
}

0 commit comments

Comments
 (0)