12
12
13
13
namespace Magento \Catalog \Block \Product \View \Options ;
14
14
15
+ use Magento \Catalog \Pricing \Price \BasePrice ;
16
+ use Magento \Catalog \Pricing \Price \CalculateCustomOptionCatalogRule ;
15
17
use Magento \Catalog \Pricing \Price \CustomOptionPriceInterface ;
18
+ use Magento \Framework \App \ObjectManager ;
16
19
17
20
/**
18
21
* Product options section abstract block.
@@ -47,20 +50,29 @@ abstract class AbstractOptions extends \Magento\Framework\View\Element\Template
47
50
*/
48
51
protected $ _catalogHelper ;
49
52
53
+ /**
54
+ * @var CalculateCustomOptionCatalogRule
55
+ */
56
+ private $ calculateCustomOptionCatalogRule ;
57
+
50
58
/**
51
59
* @param \Magento\Framework\View\Element\Template\Context $context
52
60
* @param \Magento\Framework\Pricing\Helper\Data $pricingHelper
53
61
* @param \Magento\Catalog\Helper\Data $catalogData
54
62
* @param array $data
63
+ * @param CalculateCustomOptionCatalogRule $calculateCustomOptionCatalogRule
55
64
*/
56
65
public function __construct (
57
66
\Magento \Framework \View \Element \Template \Context $ context ,
58
67
\Magento \Framework \Pricing \Helper \Data $ pricingHelper ,
59
68
\Magento \Catalog \Helper \Data $ catalogData ,
60
- array $ data = []
69
+ array $ data = [],
70
+ CalculateCustomOptionCatalogRule $ calculateCustomOptionCatalogRule = null
61
71
) {
62
72
$ this ->pricingHelper = $ pricingHelper ;
63
73
$ this ->_catalogHelper = $ catalogData ;
74
+ $ this ->calculateCustomOptionCatalogRule = $ calculateCustomOptionCatalogRule
75
+ ?? ObjectManager::getInstance ()->get (CalculateCustomOptionCatalogRule::class);
64
76
parent ::__construct ($ context , $ data );
65
77
}
66
78
@@ -112,7 +124,6 @@ public function getOption()
112
124
* Retrieve formatted price
113
125
*
114
126
* @return string
115
- * @since 102.0.6
116
127
*/
117
128
public function getFormattedPrice ()
118
129
{
@@ -132,7 +143,7 @@ public function getFormattedPrice()
132
143
*
133
144
* @return string
134
145
*
135
- * @deprecated 102.0.6
146
+ * @deprecated
136
147
* @see getFormattedPrice()
137
148
*/
138
149
public function getFormatedPrice ()
@@ -162,6 +173,15 @@ protected function _formatPrice($value, $flag = true)
162
173
$ priceStr = $ sign ;
163
174
164
175
$ customOptionPrice = $ this ->getProduct ()->getPriceInfo ()->getPrice ('custom_option_price ' );
176
+
177
+ if (!$ value ['is_percent ' ]) {
178
+ $ value ['pricing_value ' ] = $ this ->calculateCustomOptionCatalogRule ->execute (
179
+ $ this ->getProduct (),
180
+ (float )$ value ['pricing_value ' ],
181
+ (bool )$ value ['is_percent ' ]
182
+ );
183
+ }
184
+
165
185
$ context = [CustomOptionPriceInterface::CONFIGURATION_OPTION_FLAG => true ];
166
186
$ optionAmount = $ customOptionPrice ->getCustomAmount ($ value ['pricing_value ' ], null , $ context );
167
187
$ priceStr .= $ this ->getLayout ()->getBlock ('product.price.render.default ' )->renderAmount (
0 commit comments