From c9bb1d39a4f367e95e38a3e8d54e0aa2d8120ea8 Mon Sep 17 00:00:00 2001 From: Jiten Patel Date: Thu, 23 Apr 2020 12:59:50 +0530 Subject: [PATCH 1/7] Fixed Issue 12225: Tier pricing tax shows only including tax --- app/code/Magento/Catalog/Pricing/Price/TierPrice.php | 11 ++++++++++- .../Block/Product/View/Type/Configurable.php | 1 + .../base/templates/product/price/tier_price.phtml | 1 + 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Pricing/Price/TierPrice.php b/app/code/Magento/Catalog/Pricing/Price/TierPrice.php index f250927889c29..de5ec3a50030c 100644 --- a/app/code/Magento/Catalog/Pricing/Price/TierPrice.php +++ b/app/code/Magento/Catalog/Pricing/Price/TierPrice.php @@ -61,6 +61,10 @@ class TierPrice extends AbstractPrice implements TierPriceInterface, BasePricePr * @var CustomerGroupRetrieverInterface */ private $customerGroupRetriever; + /** + * @var \Magento\Framework\App\Config\ScopeConfigInterface + */ + private $scopeConfig; /** * @param Product $saleableItem @@ -78,7 +82,8 @@ public function __construct( \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, Session $customerSession, GroupManagementInterface $groupManagement, - CustomerGroupRetrieverInterface $customerGroupRetriever = null + CustomerGroupRetrieverInterface $customerGroupRetriever = null, + \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig ) { $quantity = (float)$quantity ? $quantity : 1; parent::__construct($saleableItem, $quantity, $calculator, $priceCurrency); @@ -91,6 +96,7 @@ public function __construct( } else { $this->customerGroup = (int) $this->customerGroupRetriever->getCustomerGroupId(); } + $this->scopeConfig = $scopeConfig; } /** @@ -157,6 +163,9 @@ function (&$priceData) { /* convert string value to float */ $priceData['price_qty'] = $priceData['price_qty'] * 1; $priceData['price'] = $this->applyAdjustment($priceData['price']); + if ($this->scopeConfig->getValue('tax/display/type') == 3) { + $priceData['excl_tax_price'] = $this->applyAdjustment($priceData['excl_tax_price'], true); + } } ); } diff --git a/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php index 55c0c8f6ca4ce..3e525b8be5947 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php @@ -295,6 +295,7 @@ protected function getOptionPrices() $tierPrices[] = [ 'qty' => $this->localeFormat->getNumber($tierPrice['price_qty']), 'price' => $this->localeFormat->getNumber($tierPrice['price']->getValue()), + 'excl_tax_price' => (is_object($tierPrice['excl_tax_price'])) ? $this->localeFormat->getNumber($tierPrice['excl_tax_price']->getValue()) : $tierPrice['base_price'], 'percentage' => $this->localeFormat->getNumber( $tierPriceModel->getSavePercent($tierPrice['price']) ), diff --git a/app/code/Magento/ConfigurableProduct/view/base/templates/product/price/tier_price.phtml b/app/code/Magento/ConfigurableProduct/view/base/templates/product/price/tier_price.phtml index c68419b955e6d..d2237fb9df593 100644 --- a/app/code/Magento/ConfigurableProduct/view/base/templates/product/price/tier_price.phtml +++ b/app/code/Magento/ConfigurableProduct/view/base/templates/product/price/tier_price.phtml @@ -11,6 +11,7 @@ + '' + '' + priceUtils.formatPrice(item.price, currencyFormat) + '' + + ' excl. tax ' + priceUtils.formatPrice(item.excl_tax_price, currencyFormat) + ' + '' + ''; %>
  • From e4be19bc290ecc45251c30a8e5a4d86676e531ba Mon Sep 17 00:00:00 2001 From: "vadim.malesh" Date: Thu, 10 Sep 2020 14:02:00 +0300 Subject: [PATCH 2/7] fix tier price show only including price --- .../Catalog/Pricing/Price/TierPrice.php | 69 ++++++++++---- .../Block/Product/View/Type/Configurable.php | 91 +++++++++++-------- .../templates/product/price/tier_price.phtml | 6 +- .../Magento/blank/web/css/source/_price.less | 16 ++++ 4 files changed, 124 insertions(+), 58 deletions(-) diff --git a/app/code/Magento/Catalog/Pricing/Price/TierPrice.php b/app/code/Magento/Catalog/Pricing/Price/TierPrice.php index 64b706433ad11..d50cac0951152 100644 --- a/app/code/Magento/Catalog/Pricing/Price/TierPrice.php +++ b/app/code/Magento/Catalog/Pricing/Price/TierPrice.php @@ -9,19 +9,27 @@ use Magento\Catalog\Model\Product; use Magento\Customer\Api\GroupManagementInterface; use Magento\Customer\Model\Session; +use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\App\ObjectManager; use Magento\Framework\Pricing\Adjustment\CalculatorInterface; use Magento\Framework\Pricing\Amount\AmountInterface; use Magento\Framework\Pricing\Price\AbstractPrice; use Magento\Framework\Pricing\Price\BasePriceProviderInterface; +use Magento\Framework\Pricing\PriceCurrencyInterface; use Magento\Framework\Pricing\PriceInfoInterface; use Magento\Customer\Model\Group\RetrieverInterface as CustomerGroupRetrieverInterface; +use Magento\Tax\Model\Config; /** * @api * @since 100.0.2 + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + * @SuppressWarnings(PHPMD.CookieAndSessionMisuse) */ class TierPrice extends AbstractPrice implements TierPriceInterface, BasePriceProviderInterface { + private const XML_PATH_TAX_DISPLAY_TYPE = 'tax/display/type'; + /** * Price type tier */ @@ -61,8 +69,9 @@ class TierPrice extends AbstractPrice implements TierPriceInterface, BasePricePr * @var CustomerGroupRetrieverInterface */ private $customerGroupRetriever; + /** - * @var \Magento\Framework\App\Config\ScopeConfigInterface + * @var ScopeConfigInterface */ private $scopeConfig; @@ -70,33 +79,34 @@ class TierPrice extends AbstractPrice implements TierPriceInterface, BasePricePr * @param Product $saleableItem * @param float $quantity * @param CalculatorInterface $calculator - * @param \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency + * @param PriceCurrencyInterface $priceCurrency * @param Session $customerSession * @param GroupManagementInterface $groupManagement * @param CustomerGroupRetrieverInterface|null $customerGroupRetriever + * @param ScopeConfigInterface|null $scopeConfig */ public function __construct( Product $saleableItem, $quantity, CalculatorInterface $calculator, - \Magento\Framework\Pricing\PriceCurrencyInterface $priceCurrency, + PriceCurrencyInterface $priceCurrency, Session $customerSession, GroupManagementInterface $groupManagement, CustomerGroupRetrieverInterface $customerGroupRetriever = null, - \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig + ?ScopeConfigInterface $scopeConfig = null ) { $quantity = (float)$quantity ? $quantity : 1; parent::__construct($saleableItem, $quantity, $calculator, $priceCurrency); $this->customerSession = $customerSession; $this->groupManagement = $groupManagement; $this->customerGroupRetriever = $customerGroupRetriever - ?? \Magento\Framework\App\ObjectManager::getInstance()->get(CustomerGroupRetrieverInterface::class); + ?? ObjectManager::getInstance()->get(CustomerGroupRetrieverInterface::class); if ($saleableItem->hasCustomerGroupId()) { $this->customerGroup = (int) $saleableItem->getCustomerGroupId(); } else { $this->customerGroup = (int) $this->customerGroupRetriever->getCustomerGroupId(); } - $this->scopeConfig = $scopeConfig; + $this->scopeConfig = $scopeConfig ?: ObjectManager::getInstance()->get(ScopeConfigInterface::class); } /** @@ -142,6 +152,8 @@ protected function isFirstPriceBetter($firstPrice, $secondPrice) } /** + * Returns tier price count + * * @return int */ public function getTierPriceCount() @@ -150,6 +162,8 @@ public function getTierPriceCount() } /** + * Returns tier price list + * * @return array */ public function getTierPriceList() @@ -161,18 +175,32 @@ public function getTierPriceList() $this->priceList, function (&$priceData) { /* convert string value to float */ - $priceData['price_qty'] = $priceData['price_qty'] * 1; - $priceData['price'] = $this->applyAdjustment($priceData['price']); - if ($this->scopeConfig->getValue('tax/display/type') == 3) { - $priceData['excl_tax_price'] = $this->applyAdjustment($priceData['excl_tax_price'], true); + $priceData['price_qty'] *= 1; + if ($this->getConfigTaxDisplayType() === Config::DISPLAY_TYPE_BOTH) { + $exclTaxPrice = $this->calculator->getAmount($priceData['price'], $this->product, true); + $priceData['excl_tax_price'] = $exclTaxPrice; } + $priceData['price'] = $this->applyAdjustment($priceData['price']); } ); } + return $this->priceList; } /** + * Returns config tax display type + * + * @return int + */ + private function getConfigTaxDisplayType(): int + { + return (int) $this->scopeConfig->getValue(self::XML_PATH_TAX_DISPLAY_TYPE); + } + + /** + * Filters tier prices + * * @param array $priceList * @return array */ @@ -213,6 +241,8 @@ protected function filterTierPrices(array $priceList) } /** + * Returns base price + * * @return float */ protected function getBasePrice() @@ -222,27 +252,24 @@ protected function getBasePrice() } /** - * Calculates savings percentage according to the given tier price amount - * and related product price amount. + * Calculates savings percentage according to the given tier price amount and related product price amount. * * @param AmountInterface $amount - * * @return float */ public function getSavePercent(AmountInterface $amount) { - $productPriceAmount = $this->priceInfo->getPrice( - FinalPrice::PRICE_CODE - )->getAmount(); + $productPriceAmount = $this->priceInfo->getPrice(FinalPrice::PRICE_CODE) + ->getAmount(); - return round( - 100 - ((100 / $productPriceAmount->getValue()) * $amount->getValue()) - ); + return round(100 - ((100 / $productPriceAmount->getValue()) * $amount->getValue())); } /** + * Apply adjustment to price + * * @param float|string $price - * @return \Magento\Framework\Pricing\Amount\AmountInterface + * @return AmountInterface */ protected function applyAdjustment($price) { @@ -323,6 +350,8 @@ protected function getStoredTierPrices() } /** + * Return is percentage discount + * * @return bool */ public function isPercentageDiscount() diff --git a/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php b/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php index 761b239d3477b..294a2b177145a 100644 --- a/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php +++ b/app/code/Magento/ConfigurableProduct/Block/Product/View/Type/Configurable.php @@ -7,6 +7,7 @@ */ namespace Magento\ConfigurableProduct\Block\Product\View\Type; +use Magento\Catalog\Api\Data\ProductInterface; use Magento\Catalog\Model\Product\Attribute\Source\Status; use Magento\ConfigurableProduct\Model\ConfigurableAttributeData; use Magento\Customer\Helper\Session\CurrentCustomer; @@ -287,49 +288,65 @@ protected function getOptionPrices() { $prices = []; foreach ($this->getAllowProducts() as $product) { - $tierPrices = []; $priceInfo = $product->getPriceInfo(); - $tierPriceModel = $priceInfo->getPrice('tier_price'); - $tierPricesList = $tierPriceModel->getTierPriceList(); - foreach ($tierPricesList as $tierPrice) { - $tierPrices[] = [ - 'qty' => $this->localeFormat->getNumber($tierPrice['price_qty']), - 'price' => $this->localeFormat->getNumber($tierPrice['price']->getValue()), - 'excl_tax_price' => (is_object($tierPrice['excl_tax_price'])) ? $this->localeFormat->getNumber($tierPrice['excl_tax_price']->getValue()) : $tierPrice['base_price'], - 'percentage' => $this->localeFormat->getNumber( - $tierPriceModel->getSavePercent($tierPrice['price']) - ), - ]; - } - $prices[$product->getId()] = - [ - 'oldPrice' => [ - 'amount' => $this->localeFormat->getNumber( - $priceInfo->getPrice('regular_price')->getAmount()->getValue() - ), - ], - 'basePrice' => [ - 'amount' => $this->localeFormat->getNumber( - $priceInfo->getPrice('final_price')->getAmount()->getBaseAmount() - ), - ], - 'finalPrice' => [ - 'amount' => $this->localeFormat->getNumber( - $priceInfo->getPrice('final_price')->getAmount()->getValue() - ), - ], - 'tierPrices' => $tierPrices, - 'msrpPrice' => [ - 'amount' => $this->localeFormat->getNumber( - $product->getMsrp() - ), - ], - ]; + $prices[$product->getId()] = [ + 'oldPrice' => [ + 'amount' => $this->localeFormat->getNumber( + $priceInfo->getPrice('regular_price')->getAmount()->getValue() + ), + ], + 'basePrice' => [ + 'amount' => $this->localeFormat->getNumber( + $priceInfo->getPrice('final_price')->getAmount()->getBaseAmount() + ), + ], + 'finalPrice' => [ + 'amount' => $this->localeFormat->getNumber( + $priceInfo->getPrice('final_price')->getAmount()->getValue() + ), + ], + 'tierPrices' => $this->getTierPricesByProduct($product), + 'msrpPrice' => [ + 'amount' => $this->localeFormat->getNumber( + $product->getMsrp() + ), + ], + ]; } + return $prices; } + /** + * Returns product's tier prices list + * + * @param ProductInterface $product + * @return array + */ + private function getTierPricesByProduct(ProductInterface $product): array + { + $tierPrices = []; + $tierPriceModel = $product->getPriceInfo()->getPrice('tier_price'); + foreach ($tierPriceModel->getTierPriceList() as $tierPrice) { + $tierPriceData = [ + 'qty' => $this->localeFormat->getNumber($tierPrice['price_qty']), + 'price' => $this->localeFormat->getNumber($tierPrice['price']->getValue()), + 'percentage' => $this->localeFormat->getNumber( + $tierPriceModel->getSavePercent($tierPrice['price']) + ), + ]; + + if (isset($tierPrice['excl_tax_price'])) { + $excludingTax = $tierPrice['excl_tax_price']; + $tierPriceData['excl_tax_price'] = $this->localeFormat->getNumber($excludingTax->getBaseAmount()); + } + $tierPrices[] = $tierPriceData; + } + + return $tierPrices; + } + /** * Replace ',' on '.' for js * diff --git a/app/code/Magento/ConfigurableProduct/view/base/templates/product/price/tier_price.phtml b/app/code/Magento/ConfigurableProduct/view/base/templates/product/price/tier_price.phtml index d2237fb9df593..7849fac7f2d6d 100644 --- a/app/code/Magento/ConfigurableProduct/view/base/templates/product/price/tier_price.phtml +++ b/app/code/Magento/ConfigurableProduct/view/base/templates/product/price/tier_price.phtml @@ -11,7 +11,6 @@ + '' + '' + priceUtils.formatPrice(item.price, currencyFormat) + '' - + ' excl. tax ' + priceUtils.formatPrice(item.excl_tax_price, currencyFormat) + ' + '' + ''; %>
  • @@ -22,6 +21,11 @@ escapeHtml(__('save')) ?> <%= item.percentage %>% + <% if (item['excl_tax_price']) { %> + + <%= priceUtils.formatPrice(item['excl_tax_price'], currencyFormat) %> + + <% } %>
  • <% }); %> diff --git a/app/design/frontend/Magento/blank/web/css/source/_price.less b/app/design/frontend/Magento/blank/web/css/source/_price.less index 389e7db3dd008..c91f68f11bf64 100644 --- a/app/design/frontend/Magento/blank/web/css/source/_price.less +++ b/app/design/frontend/Magento/blank/web/css/source/_price.less @@ -73,4 +73,20 @@ .price-style-1(); .price-style-3(); + + .prices-tier.items { + .price-excluding-tax { + display: block; + + &:before { + content: attr(data-label) ': '; + .lib-font-size(11); + } + + .price { + font-size: 1.2rem; + font-weight: 700; + } + } + } } From f18aaf616998ec9b7b2235c543ae7447d9c4b0a4 Mon Sep 17 00:00:00 2001 From: "vadim.malesh" Date: Mon, 14 Sep 2020 16:43:45 +0300 Subject: [PATCH 3/7] mftf coverage --- ...ontAssertExcludingTierPriceActionGroup.xml | 25 ++++ .../StorefrontProductInfoMainSection.xml | 1 + ...gurableProductWithTierPriceWithTaxTest.xml | 125 ++++++++++++++++++ 3 files changed, 151 insertions(+) create mode 100644 app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/StorefrontAssertExcludingTierPriceActionGroup.xml create mode 100644 app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductWithTierPriceWithTaxTest.xml diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/StorefrontAssertExcludingTierPriceActionGroup.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/StorefrontAssertExcludingTierPriceActionGroup.xml new file mode 100644 index 0000000000000..2dbf05e8ef498 --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/StorefrontAssertExcludingTierPriceActionGroup.xml @@ -0,0 +1,25 @@ + + + + + + + Assert product item tier price excluding price. + + + + + + + + {{excludingPrice}} + tierPriceExcluding + + + diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/StorefrontProductInfoMainSection.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/StorefrontProductInfoMainSection.xml index 37c129dc3bbde..460040431bb97 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/StorefrontProductInfoMainSection.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Section/StorefrontProductInfoMainSection.xml @@ -23,5 +23,6 @@ + diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductWithTierPriceWithTaxTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductWithTierPriceWithTaxTest.xml new file mode 100644 index 0000000000000..60711438301dd --- /dev/null +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductWithTierPriceWithTaxTest.xml @@ -0,0 +1,125 @@ + + + + + + + + + <description value="Create configurable product with tier price and check excluding tax item price"/> + <severity value="MAJOR"/> + <group value="ConfigurableProduct"/> + </annotations> + <before> + <createData entity="productAttributeWithTwoOptionsNotVisible" stepKey="createConfigProductAttribute"/> + <createData entity="productAttributeOption1" stepKey="createConfigProductAttributeOptionOne"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </createData> + <createData entity="productAttributeOption2" stepKey="createConfigProductAttributeOptionTwo"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </createData> + <createData entity="AddToDefaultSet" stepKey="createConfigAddToAttributeSet"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </createData> + <getData entity="ProductAttributeOptionGetter" index="1" stepKey="getConfigAttributeOptionOne"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </getData> + <getData entity="ProductAttributeOptionGetter" index="2" stepKey="getConfigAttributeOptionTwo"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + </getData> + + <createData entity="ApiSimpleOne" stepKey="createFirstSimpleProduct"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + <requiredEntity createDataKey="getConfigAttributeOptionOne"/> + </createData> + <createData entity="ApiSimpleTwo" stepKey="createSecondSimpleProduct"> + <requiredEntity createDataKey="createConfigProductAttribute"/> + <requiredEntity createDataKey="getConfigAttributeOptionTwo"/> + </createData> + + <createData entity="tierProductPrice" stepKey="addTierPrice"> + <requiredEntity createDataKey="createFirstSimpleProduct" /> + </createData> + + <createData entity="CustomerEntityOne" stepKey="createCustomer"/> + <createData entity="SimpleTaxRule" stepKey="createTaxRule"/> + + <magentoCLI command="config:set tax/display/type 3" stepKey="enableShowIncludingExcludingTax"/> + + <actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/> + </before> + <after> + <actionGroup ref="StorefrontCustomerLogoutActionGroup" stepKey="customerLogOut"/> + <actionGroup ref="DeleteProductUsingProductGridActionGroup" stepKey="deleteProduct"> + <argument name="product" value="ApiConfigurableProduct"/> + </actionGroup> + <actionGroup ref="AdminLogoutActionGroup" stepKey="logout"/> + + <deleteData createDataKey="createFirstSimpleProduct" stepKey="deleteFirstSimpleProduct"/> + <deleteData createDataKey="createSecondSimpleProduct" stepKey="deleteSecondSimpleProduct"/> + <deleteData createDataKey="createConfigProductAttribute" stepKey="deleteConfigProductAttribute"/> + <deleteData createDataKey="createCustomer" stepKey="deleteCustomer"/> + <deleteData createDataKey="createTaxRule" stepKey="deleteTaxRule"/> + + <magentoCLI command="config:set tax/display/type 0" stepKey="disableShowIncludingExcludingTax"/> + <magentoCron groups="index" stepKey="reindexInvalidatedIndices"/> + </after> + + <!-- Create configurable product --> + <actionGroup ref="AdminOpenProductIndexPageActionGroup" stepKey="amOnProductGridPage"/> + <actionGroup ref="GoToCreateProductPageActionGroup" stepKey="createConfigurableProduct"> + <argument name="product" value="ApiConfigurableProduct"/> + </actionGroup> + + <!-- Fill configurable product values --> + <actionGroup ref="FillMainProductFormActionGroup" stepKey="fillConfigurableProductValues"> + <argument name="product" value="ApiConfigurableProduct"/> + </actionGroup> + + <!-- Create product configurations and add attribute and select all options --> + <actionGroup ref="GenerateConfigurationsByAttributeCodeActionGroup" stepKey="generateConfigurationsByAttributeCode"> + <argument name="attributeCode" value="$$createConfigProductAttribute.attribute_code$$"/> + </actionGroup> + + <!-- Add associated products to configurations grid --> + <actionGroup ref="AddProductToConfigurationsGridActionGroup" stepKey="addFirstSimpleProduct"> + <argument name="sku" value="$$createFirstSimpleProduct.sku$$"/> + <argument name="name" value="$$createConfigProductAttributeOptionOne.option[store_labels][1][label]$$"/> + </actionGroup> + <actionGroup ref="AddProductToConfigurationsGridActionGroup" stepKey="addSecondSimpleProduct"> + <argument name="sku" value="$$createSecondSimpleProduct.sku$$"/> + <argument name="name" value="$$createConfigProductAttributeOptionTwo.option[store_labels][1][label]$$"/> + </actionGroup> + + <!-- Save configurable product --> + <actionGroup ref="SaveProductFormActionGroup" stepKey="saveConfigurableProduct"/> + + <!--Login customer on storefront--> + <actionGroup ref="LoginToStorefrontActionGroup" stepKey="loginCustomer"> + <argument name="Customer" value="$$createCustomer$$" /> + </actionGroup> + + <!-- Assert product tier price on product page --> + <amOnPage url="{{ApiConfigurableProduct.urlKey}}.html" stepKey="amOnProductPage"/> + <waitForPageLoad stepKey="waitForProductPageLoad"/> + <selectOption userInput="$$createConfigProductAttributeOptionOne.option[store_labels][1][label]$$" + selector="{{StorefrontProductInfoMainSection.productAttributeOptionsSelectButton}}" + stepKey="selectOption"/> + <grabTextFrom selector="{{StorefrontProductInfoMainSection.tierPriceText}}" stepKey="tierPriceText"/> + <assertStringContainsString stepKey="assertTierPriceTextOnProductPage"> + <expectedResult type="string">Buy {{tierProductPrice.quantity}} for $97.43 each and save 27%</expectedResult> + <actualResult type="variable">tierPriceText</actualResult> + </assertStringContainsString> + + <!-- Assert tier price excluding price --> + <actionGroup ref="StorefrontAssertExcludingTierPriceActionGroup" stepKey="assertTierPriceExcludingPrice"> + <argument name="excludingPrice" value="${{tierProductPrice.price}}" /> + </actionGroup> + </test> +</tests> From 182edf6e52d4e2f574d80b9e7ea6738acfffe2b1 Mon Sep 17 00:00:00 2001 From: "vadim.malesh" <engcom-vendorworker-charlie@adobe.com> Date: Wed, 16 Sep 2020 12:19:28 +0300 Subject: [PATCH 4/7] revert return type --- app/code/Magento/Catalog/Pricing/Price/TierPrice.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/code/Magento/Catalog/Pricing/Price/TierPrice.php b/app/code/Magento/Catalog/Pricing/Price/TierPrice.php index d50cac0951152..0434f0572135b 100644 --- a/app/code/Magento/Catalog/Pricing/Price/TierPrice.php +++ b/app/code/Magento/Catalog/Pricing/Price/TierPrice.php @@ -269,7 +269,7 @@ public function getSavePercent(AmountInterface $amount) * Apply adjustment to price * * @param float|string $price - * @return AmountInterface + * @return \Magento\Framework\Pricing\Amount\AmountInterface */ protected function applyAdjustment($price) { From 59d5d3093c97485691f96d888b18d92132c39e64 Mon Sep 17 00:00:00 2001 From: "vadim.malesh" <engcom-vendorworker-charlie@adobe.com> Date: Fri, 18 Sep 2020 14:46:49 +0300 Subject: [PATCH 5/7] fix excl price format --- .../templates/product/price/tier_price.phtml | 45 +++++++++++-------- .../Magento/blank/web/css/source/_price.less | 16 ------- 2 files changed, 26 insertions(+), 35 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/view/base/templates/product/price/tier_price.phtml b/app/code/Magento/ConfigurableProduct/view/base/templates/product/price/tier_price.phtml index 7849fac7f2d6d..7ce1fd2ccb451 100644 --- a/app/code/Magento/ConfigurableProduct/view/base/templates/product/price/tier_price.phtml +++ b/app/code/Magento/ConfigurableProduct/view/base/templates/product/price/tier_price.phtml @@ -6,27 +6,34 @@ ?> <script type="text/x-magento-template" id="tier-prices-template"> <ul class="prices-tier items"> + <% var exclPrice = ' <span class="price-wrapper price-excluding-tax"' + + 'data-label="<?= $block->escapeHtml(__('Excl. Tax')) ?>">' + + '<span class="price"> %1</span>' + + '</span>' + %> + <% _.each(tierPrices, function(item, key) { %> - <% var priceStr = '<span class="price-container price-tier_price">' - + '<span data-price-amount="' + priceUtils.formatPrice(item.price, currencyFormat) + '"' - + ' data-price-type=""' + ' class="price-wrapper ">' - + '<span class="price">' + priceUtils.formatPrice(item.price, currencyFormat) + '</span>' - + '</span>' - + '</span>'; %> - <li class="item"> - <%= '<?= $block->escapeHtml(__('Buy %1 for %2 each and', '%1', '%2')) ?>' - .replace('%1', item.qty) - .replace('%2', priceStr) %> - <strong class="benefit"> - <?= $block->escapeHtml(__('save')) ?><span + <% var itemExclPrice = item.hasOwnProperty('excl_tax_price') + ? exclPrice.replace('%1', priceUtils.formatPrice(item['excl_tax_price'], currencyFormat)) + : '' + %> + + <% var priceStr = '<span class="price-container price-tier_price">' + + '<span data-price-amount="' + priceUtils.formatPrice(item.price, currencyFormat) + '"' + + ' data-price-type=""' + ' class="price-wrapper price-including-tax">' + + '<span class="price">' + priceUtils.formatPrice(item.price, currencyFormat) + '</span>' + + '</span>' + itemExclPrice + '</span>'; + %> + <li class="item"> + <%= '<?= $block->escapeHtml(__('Buy %1 for %2 each and', '%1', '%2')) ?>' + .replace('%1', item.qty) + .replace('%2', priceStr) + %> + <strong class="benefit"> + <?= $block->escapeHtml(__('save')) ?><span class="percent tier-<%= key %>"> <%= item.percentage %></span>% - </strong> - <% if (item['excl_tax_price']) { %> - <span class="price-excluding-tax" data-label="<?= $block->escapeHtml(__('Excl. Tax')) ?>"> - <span class="price"><%= priceUtils.formatPrice(item['excl_tax_price'], currencyFormat) %></span> - </span> - <% } %> - </li> + </strong> + </li> <% }); %> </ul> </script> diff --git a/app/design/frontend/Magento/blank/web/css/source/_price.less b/app/design/frontend/Magento/blank/web/css/source/_price.less index c91f68f11bf64..389e7db3dd008 100644 --- a/app/design/frontend/Magento/blank/web/css/source/_price.less +++ b/app/design/frontend/Magento/blank/web/css/source/_price.less @@ -73,20 +73,4 @@ .price-style-1(); .price-style-3(); - - .prices-tier.items { - .price-excluding-tax { - display: block; - - &:before { - content: attr(data-label) ': '; - .lib-font-size(11); - } - - .price { - font-size: 1.2rem; - font-weight: 700; - } - } - } } From 659a6d9c06e253816674464026ef74dd26c6e4f3 Mon Sep 17 00:00:00 2001 From: "vadim.malesh" <engcom-vendorworker-charlie@adobe.com> Date: Fri, 18 Sep 2020 15:42:42 +0300 Subject: [PATCH 6/7] refactor mftf --- ...StorefrontAssertExcludingTierPriceActionGroup.xml | 4 ++-- ...inConfigurableProductWithTierPriceWithTaxTest.xml | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/StorefrontAssertExcludingTierPriceActionGroup.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/StorefrontAssertExcludingTierPriceActionGroup.xml index 2dbf05e8ef498..d609fb0346900 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/StorefrontAssertExcludingTierPriceActionGroup.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/ActionGroup/StorefrontAssertExcludingTierPriceActionGroup.xml @@ -17,9 +17,9 @@ </arguments> <grabTextFrom selector="{{StorefrontProductInfoMainSection.tierPriceExcludingPrice}}" stepKey="tierPriceExcluding"/> - <assertEquals stepKey="assertTierPriceTextOnProductPage"> + <assertStringContainsString stepKey="assertTierPriceTextOnProductPage"> <expectedResult type="string">{{excludingPrice}}</expectedResult> <actualResult type="variable">tierPriceExcluding</actualResult> - </assertEquals> + </assertStringContainsString> </actionGroup> </actionGroups> diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductWithTierPriceWithTaxTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductWithTierPriceWithTaxTest.xml index 60711438301dd..d47d5a39ae759 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductWithTierPriceWithTaxTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductWithTierPriceWithTaxTest.xml @@ -111,13 +111,13 @@ <selectOption userInput="$$createConfigProductAttributeOptionOne.option[store_labels][1][label]$$" selector="{{StorefrontProductInfoMainSection.productAttributeOptionsSelectButton}}" stepKey="selectOption"/> - <grabTextFrom selector="{{StorefrontProductInfoMainSection.tierPriceText}}" stepKey="tierPriceText"/> - <assertStringContainsString stepKey="assertTierPriceTextOnProductPage"> - <expectedResult type="string">Buy {{tierProductPrice.quantity}} for $97.43 each and save 27%</expectedResult> - <actualResult type="variable">tierPriceText</actualResult> - </assertStringContainsString> - <!-- Assert tier price excluding price --> + <!-- Assert tier price excluding including price item --> + <actionGroup ref="AssertStorefrontProductDetailPageTierPriceActionGroup" stepKey="assertProductTierPriceExcludingIncludingTax"> + <argument name="tierProductPriceDiscountQuantity" value="2"/> + <argument name="productPriceWithAppliedTierPriceDiscount" value="97.43 ${{tierProductPrice.price}}"/> + <argument name="productSavedPricePercent" value="27"/> + </actionGroup> <actionGroup ref="StorefrontAssertExcludingTierPriceActionGroup" stepKey="assertTierPriceExcludingPrice"> <argument name="excludingPrice" value="${{tierProductPrice.price}}" /> </actionGroup> From 4bed3cbf91b11b035e9494a493e282b3ff9fffbe Mon Sep 17 00:00:00 2001 From: Vadim Malesh <51680850+engcom-Charlie@users.noreply.github.com> Date: Wed, 23 Sep 2020 10:31:59 +0300 Subject: [PATCH 7/7] add testCaseId --- .../Test/AdminConfigurableProductWithTierPriceWithTaxTest.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductWithTierPriceWithTaxTest.xml b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductWithTierPriceWithTaxTest.xml index d47d5a39ae759..bbd72bbaa02da 100644 --- a/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductWithTierPriceWithTaxTest.xml +++ b/app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminConfigurableProductWithTierPriceWithTaxTest.xml @@ -14,6 +14,7 @@ <title value="Create configurable product with tier price and check excluding tax item price"/> <description value="Create configurable product with tier price and check excluding tax item price"/> <severity value="MAJOR"/> + <testCaseId value="MC-37863"/> <group value="ConfigurableProduct"/> </annotations> <before>