|
12 | 12 |
|
13 | 13 | namespace Magento\Catalog\Block\Product\View\Options;
|
14 | 14 |
|
15 |
| -use Magento\Catalog\Pricing\Price\BasePrice; |
16 | 15 | use Magento\Catalog\Pricing\Price\CalculateCustomOptionCatalogRule;
|
17 | 16 | use Magento\Catalog\Pricing\Price\CustomOptionPriceInterface;
|
18 | 17 | use Magento\Framework\App\ObjectManager;
|
| 18 | +use Magento\Framework\Pricing\Adjustment\CalculatorInterface; |
19 | 19 |
|
20 | 20 | /**
|
21 | 21 | * Product options section abstract block.
|
@@ -55,24 +55,33 @@ abstract class AbstractOptions extends \Magento\Framework\View\Element\Template
|
55 | 55 | */
|
56 | 56 | private $calculateCustomOptionCatalogRule;
|
57 | 57 |
|
| 58 | + /** |
| 59 | + * @var CalculatorInterface |
| 60 | + */ |
| 61 | + protected $calculator; |
| 62 | + |
58 | 63 | /**
|
59 | 64 | * @param \Magento\Framework\View\Element\Template\Context $context
|
60 | 65 | * @param \Magento\Framework\Pricing\Helper\Data $pricingHelper
|
61 | 66 | * @param \Magento\Catalog\Helper\Data $catalogData
|
62 | 67 | * @param array $data
|
63 | 68 | * @param CalculateCustomOptionCatalogRule|null $calculateCustomOptionCatalogRule
|
| 69 | + * @param CalculatorInterface|null $calculator |
64 | 70 | */
|
65 | 71 | public function __construct(
|
66 | 72 | \Magento\Framework\View\Element\Template\Context $context,
|
67 | 73 | \Magento\Framework\Pricing\Helper\Data $pricingHelper,
|
68 | 74 | \Magento\Catalog\Helper\Data $catalogData,
|
69 | 75 | array $data = [],
|
70 |
| - CalculateCustomOptionCatalogRule $calculateCustomOptionCatalogRule = null |
| 76 | + CalculateCustomOptionCatalogRule $calculateCustomOptionCatalogRule = null, |
| 77 | + CalculatorInterface $calculator = null |
71 | 78 | ) {
|
72 | 79 | $this->pricingHelper = $pricingHelper;
|
73 | 80 | $this->_catalogHelper = $catalogData;
|
74 | 81 | $this->calculateCustomOptionCatalogRule = $calculateCustomOptionCatalogRule
|
75 | 82 | ?? ObjectManager::getInstance()->get(CalculateCustomOptionCatalogRule::class);
|
| 83 | + $this->calculator = $calculator |
| 84 | + ?? ObjectManager::getInstance()->get(CalculatorInterface::class); |
76 | 85 | parent::__construct($context, $data);
|
77 | 86 | }
|
78 | 87 |
|
@@ -188,7 +197,9 @@ protected function _formatPrice($value, $flag = true)
|
188 | 197 | }
|
189 | 198 |
|
190 | 199 | $context = [CustomOptionPriceInterface::CONFIGURATION_OPTION_FLAG => true];
|
191 |
| - $optionAmount = $customOptionPrice->getCustomAmount($value['pricing_value'], null, $context); |
| 200 | + $optionAmount = !$isPercent |
| 201 | + ? $customOptionPrice->getCustomAmount($value['pricing_value'], null, $context) |
| 202 | + : $this->calculator->getAmount($value['pricing_value'], $this->getProduct(), null, $context); |
192 | 203 | $priceStr .= $this->getLayout()->getBlock('product.price.render.default')->renderAmount(
|
193 | 204 | $optionAmount,
|
194 | 205 | $customOptionPrice,
|
|
0 commit comments