Skip to content

#26583 Tier pricing save percent showing logic updated in product detail page #26584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AssertStorefrontProductDetailPageFinalPriceActionGroup">
<arguments>
<argument name="finalProductPrice" type="string"/>
</arguments>
<grabTextFrom selector="{{StorefrontProductInfoMainSection.price}}" stepKey="productPriceText"/>
<assertEquals stepKey="assertProductPriceOnProductPage">
<expectedResult type="string">${{finalProductPrice}}</expectedResult>
<actualResult type="variable">productPriceText</actualResult>
</assertEquals>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AssertStorefrontProductDetailPageNameActionGroup">
<arguments>
<argument name="productName" type="string"/>
</arguments>
<grabTextFrom selector="{{StorefrontProductInfoMainSection.productName}}" stepKey="productNameText"/>
<assertEquals stepKey="assertProductNameOnProductPage">
<expectedResult type="string">{{productName}}</expectedResult>
<actualResult type="variable">productNameText</actualResult>
</assertEquals>
</actionGroup>
</actionGroups>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<actionGroups xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/actionGroupSchema.xsd">
<actionGroup name="AssertStorefrontProductDetailPageTierPriceActionGroup">
<arguments>
<argument name="tierProductPriceDiscountQuantity" type="string"/>
<argument name="productPriceWithAppliedTierPriceDiscount" type="string"/>
<argument name="productSavedPricePercent" type="string"/>
</arguments>
<grabTextFrom selector="{{StorefrontProductInfoMainSection.tierPriceText}}" stepKey="tierPriceText"/>
<assertEquals stepKey="assertTierPriceTextOnProductPage">
<expectedResult type="string">Buy {{tierProductPriceDiscountQuantity}} for ${{productPriceWithAppliedTierPriceDiscount}} each and save {{productSavedPricePercent}}%</expectedResult>
<actualResult type="variable">tierPriceText</actualResult>
</assertEquals>
</actionGroup>
</actionGroups>
10 changes: 9 additions & 1 deletion app/code/Magento/Catalog/Test/Mftf/Data/TierPriceData.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,12 @@
<data key="quantity">30</data>
<var key="sku" entityType="product" entityKey="sku" />
</entity>
</entities>
<entity name="tierProductPriceDiscount" type="catalogTierPrice">
<data key="price">36.00</data>
<data key="price_type">discount</data>
<data key="website_id">0</data>
<data key="customer_group">ALL GROUPS</data>
<data key="quantity">3</data>
<var key="sku" entityType="product" entityKey="sku" />
</entity>
</entities>
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
-->

<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
<test name="StoreFrontSimpleProductWithSpecialAndTierDiscountPriceTest">
<annotations>
<features value="Catalog"/>
<title value="Apply discount tier price and custom price values for simple product"/>
<description value="Apply discount tier price and custom price values for simple product"/>
<severity value="MAJOR"/>
<group value="Catalog"/>
</annotations>
<before>
<createData entity="_defaultCategory" stepKey="createCategory"/>

<createData entity="ApiSimpleProduct" stepKey="createProduct">
<requiredEntity createDataKey="createCategory"/>
<field key="price">100.00</field>
</createData>

<createData entity="tierProductPriceDiscount" stepKey="addTierPrice">
<requiredEntity createDataKey="createProduct"/>
</createData>
</before>
<after>
<deleteData createDataKey="createProduct" stepKey="deleteSimpleProduct"/>
<deleteData createDataKey="createCategory" stepKey="deleteCategory"/>
</after>

<actionGroup ref="LoginAsAdmin" stepKey="LoginAsAdmin"/>

<actionGroup ref="GoToProductPageViaIDActionGroup" stepKey="openAdminProductEditPage">
<argument name="productId" value="$createProduct.id$"/>
</actionGroup>

<actionGroup ref="AddSpecialPriceToProductActionGroup" stepKey="addSpecialPriceToProduct">
<argument name="price" value="65.00"/>
</actionGroup>

<actionGroup ref="SaveProductFormActionGroup" stepKey="saveProductForm"/>

<actionGroup ref="StorefrontOpenProductPageActionGroup" stepKey="openProductPage">
<argument name="productUrl" value="$createProduct.custom_attributes[url_key]$"/>
</actionGroup>

<actionGroup ref="AssertStorefrontProductDetailPageNameActionGroup" stepKey="assertProductNameText">
<argument name="productName" value="$createProduct.name$"/>
</actionGroup>

<actionGroup ref="AssertStorefrontProductDetailPageTierPriceActionGroup" stepKey="assertProductTierPriceText">
<argument name="tierProductPriceDiscountQuantity" value="{{tierProductPriceDiscount.quantity}}"/>
<argument name="productPriceWithAppliedTierPriceDiscount" value="64.00"/>
<argument name="productSavedPricePercent" value="2"/>
</actionGroup>

<actionGroup ref="AssertStorefrontProductDetailPageFinalPriceActionGroup" stepKey="assertProductFinalPriceText">
<argument name="finalProductPrice" value="65.00"/>
</actionGroup>
</test>
</tests>
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ $tierPrices = $tierPriceModel->getTierPriceList();
$msrpShowOnGesture = $block->getPriceType('msrp_price')->isShowPriceOnGesture();
$product = $block->getSaleableItem();
?>
<?php if (count($tierPrices)) : ?>
<?php if (count($tierPrices)): ?>
<ul class="<?= $block->escapeHtmlAttr(($block->hasListClass() ? $block->getListClass() : 'prices-tier items')) ?>">
<?php foreach ($tierPrices as $index => $price) : ?>
<?php foreach ($tierPrices as $index => $price): ?>
<li class="item">
<?php
$productId = $product->getId();
$isSaleable = $product->isSaleable();
$popupId = 'msrp-popup-' . $productId . $block->getRandomString(20);
if ($msrpShowOnGesture && $price['price']->getValue() < $product->getMsrp()) :
if ($msrpShowOnGesture && $price['price']->getValue() < $product->getMsrp()):
$addToCartUrl = '';
if ($isSaleable) {
$addToCartUrl = $this->helper(\Magento\Checkout\Helper\Cart::class)
Expand Down Expand Up @@ -60,7 +60,7 @@ $product = $block->getSaleableItem();
id="<?= $block->escapeHtmlAttr($popupId) ?>"
data-tier-price="<?= $block->escapeHtml($block->jsonEncode($tierPriceData)) ?>">
<?= $block->escapeHtml(__('Click for price')) ?></a>
<?php else :
<?php else:
$priceAmountBlock = $block->renderAmount(
$price['price'],
[
Expand All @@ -73,19 +73,20 @@ $product = $block->getSaleableItem();
?>
<?= /* @noEscape */ ($block->getShowDetailedPrice() !== false)
? __(
'Buy %1 for %2 each and <strong class="benefit">save<span class="percent tier-%3">&nbsp;%4</span>%</strong>',
'Buy %1 for %2 each and '.
'<strong class="benefit">save<span class="percent tier-%3">&nbsp;%4</span>%</strong>',
$price['price_qty'],
$priceAmountBlock,
$index,
$block->formatPercent($price['percentage_value'] ?? $tierPriceModel->getSavePercent($price['price']))
$block->formatPercent($tierPriceModel->getSavePercent($price['price']))
)
: __('Buy %1 for %2 each', $price['price_qty'], $priceAmountBlock);
?>
<?php endif; ?>
</li>
<?php endforeach; ?>
</ul>
<?php if ($msrpShowOnGesture) :?>
<?php if ($msrpShowOnGesture):?>
<script type="text/x-magento-init">
{
".product-info-main": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public function tierPricesForAllCustomerGroupsDataProvider(): array
[
['customer_group_id' => Group::CUST_GROUP_ALL, 'qty' => 2, 'percent_value' => 70],
],
['qty' => 2, 'price' => 3.00, 'percent' => 70],
['qty' => 2, 'price' => 3.00, 'percent' => 50],
],
'fixed_tier_price_with_qty_1_is_lower_than_special' => [
5,
Expand Down Expand Up @@ -313,7 +313,7 @@ public function catalogRulesDataProvider(): array
[
['customer_group_id' => Group::CUST_GROUP_ALL, 'qty' => 2, 'percent_value' => 70],
],
['qty' => 2, 'price' => 3.00, 'percent' => 70],
['qty' => 2, 'price' => 3.00, 'percent' => 25],
],
'fixed_catalog_rule_price_lower_than_tier_price' => [
2,
Expand Down