Skip to content

Commit 7ac81df

Browse files
author
Yu Tang
committed
MAGETWO-36325: Catalog Prices on Frontend do not include the cost of required Custom Option
- Add all prices when calculating max price for checkbox and multiselect option
1 parent a2503eb commit 7ac81df

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

app/code/Magento/Catalog/Pricing/Price/CustomOptionPrice.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Catalog\Pricing\Price;
77

88
use Magento\Catalog\Model\Product\Option\Value;
9+
use Magento\Catalog\Model\Product\Option;
910
use Magento\Catalog\Pricing\Price;
1011
use Magento\Framework\Pricing\Price\AbstractPrice;
1112

@@ -61,7 +62,10 @@ public function getValue()
6162
} elseif ($price < $min) {
6263
$min = $price;
6364
}
64-
if ($price > $max) {
65+
$type = $optionItem->getType();
66+
if ($type == Option::OPTION_TYPE_CHECKBOX || $type == Option::OPTION_TYPE_MULTIPLE) {
67+
$max += $price;
68+
} elseif ($price > $max) {
6569
$max = $price;
6670
}
6771
}

app/code/Magento/Catalog/Test/Unit/Pricing/Price/CustomOptionPriceTest.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Catalog\Test\Unit\Pricing\Price;
77

88
use \Magento\Catalog\Pricing\Price\CustomOptionPrice;
9+
use Magento\Catalog\Model\Product\Option;
910

1011
use Magento\Framework\Pricing\PriceInfoInterface;
1112
use Magento\Catalog\Model\Product\Option\Value;
@@ -177,7 +178,7 @@ public function testGetValue()
177178
$option2Id = 2;
178179
$option2MaxPrice = 200;
179180
$option2MinPrice = 20;
180-
$option2Type = 'choice';
181+
$option2Type = Option::OPTION_TYPE_CHECKBOX;
181182

182183
$optionsData = [
183184
[
@@ -229,7 +230,7 @@ public function testGetValue()
229230
'option_id' => $option2Id,
230231
'type' => $option2Type,
231232
'min' => 0.,
232-
'max' => $option2MaxPrice,
233+
'max' => $option2MaxPrice + $option2MinPrice,
233234
],
234235
[
235236
'option_id' => $singleValueOptionId,

0 commit comments

Comments
 (0)