From f7fb1865aac9b80d1bc57d6d1e28e78aff8bc7ee Mon Sep 17 00:00:00 2001 From: Emipro Date: Fri, 7 Dec 2018 14:33:48 +0530 Subject: [PATCH 1/4] Fixed Custom option price calculation is wrong with multi currency when option price type is percentage. --- app/code/Magento/Catalog/Block/Product/View/Options.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/code/Magento/Catalog/Block/Product/View/Options.php b/app/code/Magento/Catalog/Block/Product/View/Options.php index 0720c018f6a9b..1f8041d115f89 100644 --- a/app/code/Magento/Catalog/Block/Product/View/Options.php +++ b/app/code/Magento/Catalog/Block/Product/View/Options.php @@ -160,7 +160,7 @@ public function hasOptions() */ protected function _getPriceConfiguration($option) { - $optionPrice = $this->pricingHelper->currency($option->getPrice(true), false, false); + $optionPrice = $option->getPrice(true); $data = [ 'prices' => [ 'oldPrice' => [ @@ -195,7 +195,7 @@ protected function _getPriceConfiguration($option) ], ], 'type' => $option->getPriceType(), - 'name' => $option->getTitle() + 'name' => $option->getTitle(), ]; return $data; } @@ -231,7 +231,7 @@ public function getJsonConfig() //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(); + $config = $configObj->getConfig(); return $this->_jsonEncoder->encode($config); } From 4d84a7a5af05d347e1b726d5c4dca4d4cc7c97c6 Mon Sep 17 00:00:00 2001 From: Emipro Date: Fri, 7 Dec 2018 15:50:55 +0530 Subject: [PATCH 2/4] solved fixed price calculation --- app/code/Magento/Catalog/Block/Product/View/Options.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Block/Product/View/Options.php b/app/code/Magento/Catalog/Block/Product/View/Options.php index 1f8041d115f89..ece517d033f87 100644 --- a/app/code/Magento/Catalog/Block/Product/View/Options.php +++ b/app/code/Magento/Catalog/Block/Product/View/Options.php @@ -20,6 +20,11 @@ */ class Options extends \Magento\Framework\View\Element\Template { + /** + * Option type percent + */ + protected static $typePercent = 'percent'; + /** * @var Product */ @@ -160,7 +165,8 @@ public function hasOptions() */ protected function _getPriceConfiguration($option) { - $optionPrice = $option->getPrice(true); + $option->getPriceType() == self::$typePercent ? $optionPrice = $option->getPrice(true) : + $optionPrice = $this->pricingHelper->currency($option->getPrice(true), false, false); $data = [ 'prices' => [ 'oldPrice' => [ From 8bdedc57dcb23bb0945f28e29a9f7d22c82bdec0 Mon Sep 17 00:00:00 2001 From: Emipro Date: Sat, 9 Feb 2019 12:08:11 +0530 Subject: [PATCH 3/4] Update Code for Price Calculation --- .../Magento/Catalog/Block/Product/View/Options.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/code/Magento/Catalog/Block/Product/View/Options.php b/app/code/Magento/Catalog/Block/Product/View/Options.php index ece517d033f87..10f73b6012f66 100644 --- a/app/code/Magento/Catalog/Block/Product/View/Options.php +++ b/app/code/Magento/Catalog/Block/Product/View/Options.php @@ -12,6 +12,7 @@ namespace Magento\Catalog\Block\Product\View; use Magento\Catalog\Model\Product; +use Magento\Catalog\Model\Product\Option\Value; /** * @api @@ -20,11 +21,6 @@ */ class Options extends \Magento\Framework\View\Element\Template { - /** - * Option type percent - */ - protected static $typePercent = 'percent'; - /** * @var Product */ @@ -165,8 +161,10 @@ public function hasOptions() */ protected function _getPriceConfiguration($option) { - $option->getPriceType() == self::$typePercent ? $optionPrice = $option->getPrice(true) : - $optionPrice = $this->pricingHelper->currency($option->getPrice(true), false, false); + $optionPrice = $option->getPrice(true); + if($option->getPriceType() != Value::TYPE_PERCENT) { + $optionPrice = $this->pricingHelper->currency($optionPrice, false, false); + } $data = [ 'prices' => [ 'oldPrice' => [ From fde7fb1940d41214911bf3f91016f86524a0ff2b Mon Sep 17 00:00:00 2001 From: Pavel Bystritsky Date: Tue, 12 Feb 2019 16:30:29 +0200 Subject: [PATCH 4/4] ENGCOM-4217: Static test fix. --- .../Magento/Catalog/Block/Product/View/Options.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/code/Magento/Catalog/Block/Product/View/Options.php b/app/code/Magento/Catalog/Block/Product/View/Options.php index 10f73b6012f66..c457b20cd0904 100644 --- a/app/code/Magento/Catalog/Block/Product/View/Options.php +++ b/app/code/Magento/Catalog/Block/Product/View/Options.php @@ -4,17 +4,15 @@ * See COPYING.txt for license details. */ -/** - * Product options block - * - * @author Magento Core Team - */ namespace Magento\Catalog\Block\Product\View; use Magento\Catalog\Model\Product; use Magento\Catalog\Model\Product\Option\Value; /** + * Product options block + * + * @author Magento Core Team * @api * @SuppressWarnings(PHPMD.CouplingBetweenObjects) * @since 100.0.2 @@ -122,6 +120,8 @@ public function setProduct(Product $product = null) } /** + * Get group of option. + * * @param string $type * @return string */ @@ -143,6 +143,8 @@ public function getOptions() } /** + * Check if block has options. + * * @return bool */ public function hasOptions() @@ -162,7 +164,7 @@ public function hasOptions() protected function _getPriceConfiguration($option) { $optionPrice = $option->getPrice(true); - if($option->getPriceType() != Value::TYPE_PERCENT) { + if ($option->getPriceType() !== Value::TYPE_PERCENT) { $optionPrice = $this->pricingHelper->currency($optionPrice, false, false); } $data = [