diff --git a/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php b/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php index ef83f818e70df8d365bb0f73ac0f801131702f3d..706870380ad1dda7ede8a4422544eff1beb2afbb 100644 --- a/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php +++ b/app/code/Magento/Bundle/Block/Catalog/Product/View/Type/Bundle.php @@ -154,6 +154,16 @@ class Bundle extends \Magento\Catalog\Block\Product\View\AbstractView } $config = $this->getConfigData($currentProduct, $options); + $configObj = new \Magento\Framework\Object( + [ + 'config' => $config, + ] + ); + + //pass the return array encapsulated in an object for the other modules to be able to alter it eg: weee + $this->_eventManager->dispatch('catalog_product_option_price_configuration_after', ['configObj' => $configObj]); + $config=$configObj->getConfig(); + if ($preConfiguredFlag && !empty($defaultValues)) { $config['defaultValues'] = $defaultValues; } @@ -196,6 +206,7 @@ class Bundle extends \Magento\Catalog\Block\Product\View\AbstractView $selection = [ 'qty' => $qty, 'customQty' => $selection->getSelectionCanChangeQty(), + 'optionId' => $selection->getId(), 'prices' => [ 'oldPrice' => [ 'amount' => $basePrice diff --git a/app/code/Magento/Bundle/Test/Unit/Block/Catalog/Product/View/Type/BundleTest.php b/app/code/Magento/Bundle/Test/Unit/Block/Catalog/Product/View/Type/BundleTest.php index 021bc147762f86e25504548fc839ebb6a9cb9087..b99aca6f6310a773262bee3ff72d6d36262f6b60 100644 --- a/app/code/Magento/Bundle/Test/Unit/Block/Catalog/Product/View/Type/BundleTest.php +++ b/app/code/Magento/Bundle/Test/Unit/Block/Catalog/Product/View/Type/BundleTest.php @@ -237,6 +237,12 @@ class BundleTest extends \PHPUnit_Framework_TestCase { $objectHelper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); + + $eventManager = $this->getMockBuilder('\Magento\Framework\Event\Manager') + ->disableOriginalConstructor() + ->getMock(); + $eventManager->expects($this->any())->method('dispatch')->will($this->returnValue(true)); + $optionCollection = $this->getMockBuilder('\Magento\Bundle\Model\Resource\Option\Collection') ->disableOriginalConstructor() ->getMock(); @@ -285,6 +291,9 @@ class BundleTest extends \PHPUnit_Framework_TestCase $context->expects($this->any()) ->method('getTaxData') ->will($this->returnValue($taxHelperMock)); + $context->expects($this->any()) + ->method('getEventManager') + ->will($this->returnValue($eventManager)); $jsonEncoderMock = $this->getMockBuilder('\Magento\Framework\Json\Encoder') ->disableOriginalConstructor() diff --git a/app/code/Magento/SalesRule/view/adminhtml/templates/promo/salesrulejs.phtml b/app/code/Magento/SalesRule/view/adminhtml/templates/promo/salesrulejs.phtml index 214b703dd2556359c29f515b61cadb0b91276657..981ff86b8585d3b1d4d1ff39df5cb4177abee74a 100644 --- a/app/code/Magento/SalesRule/view/adminhtml/templates/promo/salesrulejs.phtml +++ b/app/code/Magento/SalesRule/view/adminhtml/templates/promo/salesrulejs.phtml @@ -67,7 +67,12 @@ function generateCouponCodes(idPrefix, generateUrl, grid) { var params = Form.serializeElements(elements, true); params.form_key = FORM_KEY; - $('messages').update(); + if ($$('#'+idPrefix + 'information_fieldset .messages')) { + $$('#'+idPrefix + 'information_fieldset .messages')[0].update(); + } + if ($('messages')) { + $('messages').update(); + } var couponCodesGrid = eval(grid); new Ajax.Request(generateUrl, { parameters :params, @@ -81,7 +86,11 @@ function generateCouponCodes(idPrefix, generateUrl, grid) { couponCodesGrid.reload(); } if (response && response.messages) { - $('messages').update(response.messages); + if ($$('#'+idPrefix + 'information_fieldset .messages')) { + $$('#'+idPrefix + 'information_fieldset .messages')[0].update(response.messages); + } else if ($('messages')) { + $('messages').update(response.messages); + } } if (response && response.error) { alert(response.error); diff --git a/app/code/Magento/Weee/Helper/Data.php b/app/code/Magento/Weee/Helper/Data.php index d26e01b263f0a55a0dfe5149915fba8efc479254..a3d428821614eb528a11c4cb47c09bce0fd9fbd0 100644 --- a/app/code/Magento/Weee/Helper/Data.php +++ b/app/code/Magento/Weee/Helper/Data.php @@ -7,6 +7,8 @@ namespace Magento\Weee\Helper; use Magento\Store\Model\Store; use Magento\Store\Model\Website; +use Magento\Catalog\Model\Product\Type; +use Magento\Weee\Model\Tax as WeeeDisplayConfig; /** * WEEE data helper @@ -674,4 +676,82 @@ class Data extends \Magento\Framework\App\Helper\AbstractHelper } return $weeeTotal; } + + /** + * get FPT DISPLAY_INCL setting + * + * @param int|null $storeId + * @return bool + */ + public function geDisplayIncl($storeId = null) + { + return $this->typeOfDisplay( + WeeeDisplayConfig::DISPLAY_INCL, + \Magento\Framework\Pricing\Render::ZONE_ITEM_VIEW, + $storeId + ); + } + + /** + * get FPT DISPLAY_EXCL_DESCR_INCL setting + * + * @param int|null $storeId + * @return bool + */ + public function geDisplayExlDescIncl($storeId = null) + { + return $this->typeOfDisplay( + WeeeDisplayConfig::DISPLAY_EXCL_DESCR_INCL, + \Magento\Framework\Pricing\Render::ZONE_ITEM_VIEW, + $storeId + ); + } + + /** + * get FPT DISPLAY_EXCL setting + * + * @param int|null $storeId + * @return bool + */ + public function geDisplayExcl($storeId = null) + { + return $this->typeOfDisplay( + WeeeDisplayConfig::DISPLAY_EXCL, + \Magento\Framework\Pricing\Render::ZONE_ITEM_VIEW, + $storeId + ); + } + + /** + * Return an array of FPT attributes for a bundle product + * + * @param \Magento\Catalog\Model\Product $product + * @return array + */ + public function getWeeAttributesForBundle($product) + { + if ($product->getTypeId() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) { + $typeInstance = $product->getTypeInstance(); + $typeInstance->setStoreFilter($product->getStoreId(), $product); + + $selectionCollection = $typeInstance->getSelectionsCollection( + $typeInstance->getOptionsIds($product), + $product + ); + $insertedWeeCodesArray = []; + foreach ($selectionCollection as $selectionItem) { + $weeAttributes = $this->getProductWeeeAttributes( + $selectionItem, + null, + null, + $product->getStore()->getWebsiteId() + ); + foreach ($weeAttributes as $weeAttribute) { + $insertedWeeCodesArray[$weeAttribute->getCode()]=$weeAttribute; + } + } + return $insertedWeeCodesArray; + } + return []; + } } diff --git a/app/code/Magento/Weee/Model/Observer.php b/app/code/Magento/Weee/Model/Observer.php index c5e0421eeeead2d413fd1b5d4041bd0fe2253ff6..8b97dc699731b27738498dd2941778a33bdb43d7 100644 --- a/app/code/Magento/Weee/Model/Observer.php +++ b/app/code/Magento/Weee/Model/Observer.php @@ -215,39 +215,142 @@ class Observer extends \Magento\Framework\Model\AbstractModel public function getPriceConfiguration(\Magento\Framework\Event\Observer $observer) { if ($this->_weeeData->isEnabled()) { - $priceConfigObj=$observer->getData('configObj'); - $priceConfig=$priceConfigObj->getConfig(); + $priceConfigObj = $observer->getData('configObj'); try { - if (is_array($priceConfig)) { - foreach ($priceConfig as $keyConfigs => $configs) { - if (is_array($configs)) { - foreach ($configs as $keyConfig => $config) { - $calcPrice = 'finalPrice'; - if ($this->_taxData->priceIncludesTax() && - $this->_taxData->displayPriceExcludingTax() - ) { - $calcPrice = 'basePrice'; - } - if (array_key_exists('prices', $configs)) { - $priceConfig[$keyConfigs]['prices']['weeePrice'] = [ - 'amount' => $configs['prices'][$calcPrice]['amount'], - ]; - } else { - foreach ($configs as $keyConfig => $config) { - $priceConfig[$keyConfigs][$keyConfig]['prices']['weeePrice'] = [ - 'amount' => $config['prices'][$calcPrice]['amount'], - ]; - } - } + $product = $this->_registry->registry('current_product'); + + $weeeAttributes = $this->_weeeData->getWeeAttributesForBundle($product); + + $calcPrice = 'finalPrice'; + if ($this->_taxData->priceIncludesTax() && + $this->_taxData->displayPriceExcludingTax() + ) { + $calcPrice = 'basePrice'; + } + $priceConfig = $this->recurConfigAndInsertWeeePrice( + $priceConfigObj->getConfig(), + 'prices', + $calcPrice, + $weeeAttributes + ); + $priceConfigObj->setConfig($priceConfig); + } catch (\Exception $e) { + return $this; + } + } + return $this; + } + + /** + * Recur through the config array and insert the wee price + * + * @param array $input + * @param string $searchKey + * @param string $calcPrice + * @param array $weeeAttributes + * @return array + */ + private function recurConfigAndInsertWeeePrice($input, $searchKey, $calcPrice, $weeeAttributes = null) + { + $holder = []; + if (is_array($input)) { + foreach ($input as $key => $el) { + if (is_array($el)) { + $holder[$key] = $this->recurConfigAndInsertWeeePrice($el, $searchKey, $calcPrice, $weeeAttributes); + if ($key === $searchKey) { + if ((!array_key_exists('weeePrice', $holder[$key])) && + (array_key_exists($calcPrice, $holder[$key])) + ) { + //this is required for product options && bundle + $holder[$key]['weeePrice'] = $holder[$key][$calcPrice]; + // only do processing on product options + if (array_key_exists('optionId', $input) && $weeeAttributes) { + $holder = $this->insertWeePrice($holder, $key, $weeeAttributes); } } } + } else { + $holder[$key] = $el; } - $priceConfigObj->setConfig($priceConfig); - } catch (Exception $e) { - return $this; } } + return $holder; + } + + /** + * Insert the wee price for bundle product + * + * @param array $holder + * @param int|string $key + * @param array $weeeAttributes + * @return array + */ + private function insertWeePrice($holder, $key, $weeeAttributes) + { + if (count($weeeAttributes)>0) { + $weeSum = 0; + foreach ($weeeAttributes as $weeAttribute) { + $holder[$key]['weeePrice' . $weeAttribute->getCode()] = + ['amount' => (float)$weeAttribute->getAmount()]; + $weeSum += (float)$weeAttribute->getAmount(); + } + + $holder[$key]['weeePrice']['amount'] += (float)$weeSum; + } + return $holder; + } + + /** + * Change default JavaScript templates for options rendering + * + * @param \Magento\Framework\Event\Observer $observer + * @return $this + */ + public function updateProductOptions(\Magento\Framework\Event\Observer $observer) + { + $response = $observer->getEvent()->getResponseObject(); + $options = $response->getAdditionalOptions(); + + /** @var \Magento\Catalog\Model\Product $product */ + $product = $this->_registry->registry('current_product'); + if (!$product) { + return $this; + } + + if ($this->_weeeData->isEnabled() && + !$this->_weeeData->geDisplayIncl($product->getStoreId()) && + !$this->_weeeData->geDisplayExcl($product->getStoreId()) + ) { + // only do processing on bundle product + if ($product->getTypeId() == \Magento\Catalog\Model\Product\Type::TYPE_BUNDLE) { + if (!array_key_exists('optionTemplate', $options)) { + $options['optionTemplate'] = '<%- data.label %>' + . '<% if (data.finalPrice.value) { %>' + . ' +<%- data.finalPrice.formatted %>' + . '<% } %>'; + } + + foreach ($this->_weeeData->getWeeAttributesForBundle($product) as $weeAttribute) { + $options['optionTemplate'] .= sprintf( + ' <%% if (data.weeePrice' . $weeAttribute->getCode() . ') { %%>' + . ' (' . $weeAttribute->getName() + . ':<%%= data.weeePrice' . $weeAttribute->getCode() + . '.formatted %%>)' + . '<%% } %%>' + ); + } + + if ($this->_weeeData->geDisplayExlDescIncl($product->getStoreId())) { + $options['optionTemplate'] .= sprintf( + ' <%% if (data.weeePrice) { %%>' + . '<%%= data.weeePrice.formatted %%>' + . '<%% } %%>' + ); + } + + } + } + $response->setAdditionalOptions($options); return $this; } } diff --git a/app/code/Magento/Weee/Test/Unit/Helper/DataTest.php b/app/code/Magento/Weee/Test/Unit/Helper/DataTest.php index 4a8292933b50fcc590f8983b83886c2a03929e03..6e8db3462be41df946b2a9176990204fe12e38d8 100644 --- a/app/code/Magento/Weee/Test/Unit/Helper/DataTest.php +++ b/app/code/Magento/Weee/Test/Unit/Helper/DataTest.php @@ -23,6 +23,11 @@ class DataTest extends \PHPUnit_Framework_TestCase */ protected $_product; + /** + * @var \Magento\Weee\Model\Tax + */ + protected $weeeTax; + /** * @var \Magento\Weee\Helper\Data */ @@ -33,11 +38,11 @@ class DataTest extends \PHPUnit_Framework_TestCase $this->_product = $this->getMock('Magento\Catalog\Model\Product', [], [], '', false); $weeeConfig = $this->getMock('Magento\Weee\Model\Config', [], [], '', false); $weeeConfig->expects($this->any())->method('isEnabled')->will($this->returnValue(true)); - $weeeTax = $this->getMock('Magento\Weee\Model\Tax', [], [], '', false); - $weeeTax->expects($this->any())->method('getWeeeAmount')->will($this->returnValue('11.26')); + $this->weeeTax = $this->getMock('Magento\Weee\Model\Tax', [], [], '', false); + $this->weeeTax->expects($this->any())->method('getWeeeAmount')->will($this->returnValue('11.26')); $arguments = [ 'weeeConfig' => $weeeConfig, - 'weeeTax' => $weeeTax, + 'weeeTax' => $this->weeeTax, ]; $helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this); $this->_helperData = $helper->getObject('Magento\Weee\Helper\Data', $arguments); @@ -143,4 +148,60 @@ class DataTest extends \PHPUnit_Framework_TestCase $value = $this->_helperData->getBaseWeeeTaxAmountRefunded($orderItem); $this->assertEquals(self::BASE_TAX_AMOUNT_REFUNDED, $value); } + + public function testGetWeeAttributesForBundle() + { + $weeObject = new \Magento\Framework\Object( + [ + 'code' => 'fpt', + 'amount' => '15.0000', + ] + ); + $testArray = ['fpt' => $weeObject]; + + $this->weeeTax->expects($this->any()) + ->method('getProductWeeeAttributes') + ->will($this->returnValue([$weeObject])); + + $productSimple=$this->getMock('\Magento\Catalog\Model\Product\Type\Simple', [], [], '', false); + + $productInstance=$this->getMock('\Magento\Bundle\Model\Product\Type', [], [], '', false); + $productInstance->expects($this->any()) + ->method('getSelectionsCollection') + ->will($this->returnValue([$productSimple])); + + $store=$this->getMock('\Magento\Store\Model\Store', [], [], '', false); + + + $product=$this->getMock( + '\Magento\Bundle\Model\Product', + ['getTypeInstance', 'getStoreId', 'getStore', 'getTypeId'], + [], + '', + false + ); + $product->expects($this->any()) + ->method('getTypeInstance') + ->will($this->returnValue($productInstance)); + + $product->expects($this->any()) + ->method('getStoreId') + ->will($this->returnValue(1)); + + $product->expects($this->any()) + ->method('getStore') + ->will($this->returnValue($store)); + + $product->expects($this->any()) + ->method('getTypeId') + ->will($this->returnValue('bundle')); + + $registry=$this->getMock('Magento\Framework\Registry', [], [], '', false); + $registry->expects($this->any()) + ->method('registry') + ->with('current_product') + ->will($this->returnValue($product)); + + $this->assertEquals($testArray, $this->_helperData->getWeeAttributesForBundle($product)); + } } diff --git a/app/code/Magento/Weee/Test/Unit/Model/ObserverTest.php b/app/code/Magento/Weee/Test/Unit/Model/ObserverTest.php index 63a13abb53622e5f93590a1586d695fb17e18707..1e9fb7572bfc4c7aeb494fd835c11d846b14161b 100644 --- a/app/code/Magento/Weee/Test/Unit/Model/ObserverTest.php +++ b/app/code/Magento/Weee/Test/Unit/Model/ObserverTest.php @@ -15,66 +15,326 @@ class ObserverTest extends \PHPUnit_Framework_TestCase { /** * Tests the methods that rely on the ScopeConfigInterface object to provide their return values - * + * @dataProvider getPriceConfigurationProvider + * @param array $testArray + * @param array $expectedArray */ - public function testGetPriceConfiguration() + public function testGetPriceConfiguration($testArray, $expectedArray) { - $testArray=[ - [ - [ - 'prices' => - [ - 'finalPrice' => [ - 'amount' => 31.50, - ], - ], - ], - [ - 'prices' => - [ - 'finalPrice' =>[ - 'amount' => 31.50, - ], - ], - ], - ], - ]; - $configObj = new \Magento\Framework\Object( [ 'config' => $testArray, ] ); - - $testArrayWithWeee=$testArray; - $testArrayWithWeee[0][0]['prices']['weeePrice']= [ - 'amount' => $testArray[0][0]['prices']['finalPrice']['amount'], - ]; - $testArrayWithWeee[0][1]['prices']['weeePrice']= [ - 'amount' => $testArray[0][1]['prices']['finalPrice']['amount'], - ]; - $weeHelper=$this->getMock('Magento\Weee\Helper\Data', [], [], '', false); $weeHelper->expects($this->any()) ->method('isEnabled') ->will($this->returnValue(true)); $observerObject=$this->getMock('Magento\Framework\Event\Observer', [], [], '', false); - $observerObject->expects($this->any()) ->method('getData') ->with('configObj') ->will($this->returnValue($configObj)); - $objectManager = new ObjectManager($this); + $productInstance=$this->getMock('\Magento\Catalog\Model\Product\Type\Simple', [], [], '', false); + + $product=$this->getMock('\Magento\Bundle\Model\Product\Type', ['getTypeInstance', 'getTypeId'], [], '', false); + $product->expects($this->any()) + ->method('getTypeInstance') + ->will($this->returnValue($productInstance)); + + $product->expects($this->any()) + ->method('getTypeId') + ->will($this->returnValue('simple')); + + $registry=$this->getMock('Magento\Framework\Registry', [], [], '', false); + $registry->expects($this->any()) + ->method('registry') + ->with('current_product') + ->will($this->returnValue($product)); + + + $objectManager = new ObjectManager($this); $weeeObserverObject = $objectManager->getObject( 'Magento\Weee\Model\Observer', [ 'weeeData' => $weeHelper, + 'registry' => $registry, ] ); $weeeObserverObject->getPriceConfiguration($observerObject); - $this->assertEquals($testArrayWithWeee, $configObj->getData('config')); + $this->assertEquals($expectedArray, $configObj->getData('config')); + } + + /** + * @return array + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ + public function getPriceConfigurationProvider() + { + return [ + [ + 'testArray' => [ + [ + [ + 'optionId' => 1, + 'prices' => + [ + 'finalPrice' => [ + 'amount' => 31.50, + ], + 'basePrice' => [ + 'amount' => 33.50, + ], + ], + ], + [ + 'optionId' => 2, + 'prices' => + [ + 'finalPrice' =>[ + 'amount' => 331.50, + ], + 'basePrice' => [ + 'amount' => 333.50, + ], + ], + ], + ], + ], + 'expectedArray' => [ + [ + [ + 'optionId' => 1, + 'prices' => + [ + 'finalPrice' => [ + 'amount' => 31.50, + ], + 'basePrice' => [ + 'amount' => 33.50, + ], + 'weeePrice' => [ + 'amount' => 31.50, + ], + ], + ], + [ + 'optionId' => 2, + 'prices' => + [ + 'finalPrice' =>[ + 'amount' => 331.50, + ], + 'basePrice' => [ + 'amount' => 333.50, + ], + 'weeePrice' => [ + 'amount' => 331.50, + ], + ], + ], + ], + ], + ], + [ + 'testArray' => [ + [ + [ + 'prices' => + [ + 'finalPrice' => [ + 'amount' => 31.50, + ], + ], + 'somekey' => 0, + ], + [ + [ + [ + 'prices' => + [ + 'finalPrice' =>[ + 'amount' => 31.50, + ], + ], + ], + 'otherkey' => [ 1, 2 , 3], + ] + ], + ], + ], + 'expectedArray' => [ + [ + [ + 'prices' => + [ + 'finalPrice' => [ + 'amount' => 31.50, + ], + 'weeePrice' => [ + 'amount' => 31.50, + ], + ], + 'somekey' => 0, + ], + [ + [ + [ + 'prices' => + [ + 'finalPrice' =>[ + 'amount' => 31.50, + ], + 'weeePrice' => [ + 'amount' => 31.50, + ], + ], + ], + 'otherkey' => [ 1, 2 , 3], + ] + ], + ], + ], + ], + ]; + } + + /** + * Tests the methods that rely on the ScopeConfigInterface object to provide their return values + * @dataProvider updateProductOptionsProvider + * @param array $testArray + * @param bool $weeDisplay + * @param bool $weeEnabled + * @param array $expectedArray + */ + public function testUpdateProductOptions($testArray, $weeDisplay, $weeEnabled, $expectedArray) + { + $configObj = new \Magento\Framework\Object( + [ + 'additional_options' => $testArray, + ] + ); + + $weeObject = new \Magento\Framework\Object( + [ + 'code' => 'fpt', + 'amount' => '15.0000', + ] + ); + + $weeHelper=$this->getMock('Magento\Weee\Helper\Data', [], [], '', false); + $weeHelper->expects($this->any()) + ->method('isEnabled') + ->will($this->returnValue($weeEnabled)); + + $weeHelper->expects($this->any()) + ->method('geDisplayExlDescIncl') + ->will($this->returnValue($weeDisplay)); + + $weeHelper->expects($this->any()) + ->method('getWeeAttributesForBundle') + ->will($this->returnValue([$weeObject])); + + $responseObject=$this->getMock('Magento\Framework\Event\Observer', ['getResponseObject'], [], '', false); + $responseObject->expects($this->any()) + ->method('getResponseObject') + ->will($this->returnValue($configObj)); + + $observerObject=$this->getMock('Magento\Framework\Event\Observer', ['getEvent'], [], '', false); + $observerObject->expects($this->any()) + ->method('getEvent') + ->will($this->returnValue($responseObject)); + + $product=$this->getMock( + '\Magento\Bundle\Model\Product\Type', + ['getTypeId', 'getStoreId'], + [], + '', + false + ); + $product->expects($this->any()) + ->method('getStoreId') + ->will($this->returnValue(1)); + + $product->expects($this->any()) + ->method('getTypeId') + ->will($this->returnValue('bundle')); + + $registry=$this->getMock('Magento\Framework\Registry', [], [], '', false); + $registry->expects($this->any()) + ->method('registry') + ->with('current_product') + ->will($this->returnValue($product)); + + + $objectManager = new ObjectManager($this); + $weeeObserverObject = $objectManager->getObject( + 'Magento\Weee\Model\Observer', + [ + 'weeeData' => $weeHelper, + 'registry' => $registry, + ] + ); + $weeeObserverObject->updateProductOptions($observerObject); + + $this->assertEquals($expectedArray, $configObj->getData('additional_options')); + } + + /** + * @return array + * @SuppressWarnings(PHPMD.ExcessiveMethodLength) + */ + public function updateProductOptionsProvider() + { + return [ + [ + 'testArray' => [ + 'TOTAL_BASE_CALCULATION' => 'TOTAL_BASE_CALCULATION', + 'optionTemplate' => '<%= data.label %><% if (data.basePrice.value) ' + . '{ %> +<%= data.basePrice.formatted %><% } %>', + ], + 'weeDisplay' => true, + 'weeEnabled' => false, + 'expectedArray' => [ + 'TOTAL_BASE_CALCULATION' => 'TOTAL_BASE_CALCULATION', + 'optionTemplate' => '<%= data.label %><% if (data.basePrice.value) ' + . '{ %> +<%= data.basePrice.formatted %><% } %>', + ], + ], + [ + 'testArray' => [ + 'TOTAL_BASE_CALCULATION' => 'TOTAL_BASE_CALCULATION', + 'optionTemplate' => '<%= data.label %><% if (data.basePrice.value) ' + . '{ %> +<%= data.basePrice.formatted %><% } %>', + ], + 'weeDisplay' => false, + 'weeEnabled' => true, + 'expectedArray' => [ + 'TOTAL_BASE_CALCULATION' => 'TOTAL_BASE_CALCULATION', + 'optionTemplate' => '<%= data.label %><% if (data.basePrice.value) ' + . '{ %> +<%= data.basePrice.formatted %><% } %> <% if (data.weeePricefpt) ' + . '{ %> (:<%= data.weeePricefpt.formatted %>)<% } %>', + ], + ], + [ + 'testArray' => [ + 'TOTAL_BASE_CALCULATION' => 'TOTAL_BASE_CALCULATION', + 'optionTemplate' => '<%= data.label %><% if (data.basePrice.value) ' + . '{ %> +<%= data.basePrice.formatted %><% } %>', + ], + 'weeDisplay' => true, + 'weeEnabled' => true, + 'expectedArray' => [ + 'TOTAL_BASE_CALCULATION' => 'TOTAL_BASE_CALCULATION', + 'optionTemplate' => '<%= data.label %><% if (data.basePrice.value) ' + . '{ %> +<%= data.basePrice.formatted %><% } %> <% if (data.weeePricefpt) ' + . '{ %> (:<%= data.weeePricefpt.formatted %>)<% } %> ' + . '<% if (data.weeePrice) { %><%= data.weeePrice.formatted %><% } %>', + ], + ], + ]; } } diff --git a/app/code/Magento/Weee/etc/events.xml b/app/code/Magento/Weee/etc/events.xml index f4300f38b2369817d96c1902c29c57d378676f17..9d64b14c0630da0fd5d0b372912b20b7606177a7 100644 --- a/app/code/Magento/Weee/etc/events.xml +++ b/app/code/Magento/Weee/etc/events.xml @@ -12,4 +12,7 @@ <event name="catalog_product_option_price_configuration_after"> <observer name="weee" instance="Magento\Weee\Model\Observer" method="getPriceConfiguration" shared="false" /> </event> + <event name="catalog_product_view_config"> + <observer name="weee" instance="Magento\Weee\Model\Observer" method="updateProductOptions" shared="true" /> + </event> </config>