Skip to content

Commit 3d7298e

Browse files
committed
Fix #29194 Update tier price block show & hide
1 parent 12cdc54 commit 3d7298e

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

app/code/Magento/ConfigurableProduct/Test/Mftf/Section/StorefrontProductInfoMainSection.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<element name="selectableProductOptions" type="select" selector="#attribute{{var1}} option:not([disabled])" parameterized="true"/>
1414
<element name="productAttributeTitle1" type="text" selector="#product-options-wrapper div[tabindex='0'] label"/>
1515
<element name="productPrice" type="text" selector="div.price-box.price-final_price"/>
16+
<element name="tierPriceBlock" type="block" selector="div[data-role='tier-price-block']"/>
1617
<element name="productAttributeOptions1" type="select" selector="#product-options-wrapper div[tabindex='0'] option"/>
1718
<element name="productAttributeOptionsSelectButton" type="select" selector="#product-options-wrapper .super-attribute-select"/>
1819
<element name="productAttributeOptionsError" type="text" selector="//div[@class='mage-error']"/>

app/code/Magento/ConfigurableProduct/Test/Mftf/Test/AdminCreateConfigurableProductWithTierPriceForOneItemTest.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848

4949
<!--Add tier price in one product -->
5050
<createData entity="tierProductPrice" stepKey="addTierPrice">
51-
<requiredEntity createDataKey="createFirstSimpleProduct" />
51+
<requiredEntity createDataKey="createFirstSimpleProduct" />
5252
</createData>
5353
<actionGroup ref="AdminLoginActionGroup" stepKey="loginAsAdmin"/>
5454
</before>
@@ -109,5 +109,8 @@
109109
<expectedResult type="string">Buy {{tierProductPrice.quantity}} for ${{tierProductPrice.price}} each and save 27%</expectedResult>
110110
<actualResult type="variable">tierPriceText</actualResult>
111111
</assertEquals>
112+
<seeElement selector="{{StorefrontProductInfoMainSection.tierPriceBlock}}" stepKey="seeTierPriceBlock"/>
113+
<selectOption userInput="$$createConfigProductAttributeOptionTwo.option[store_labels][1][label]$$" selector="{{StorefrontProductInfoMainSection.productAttributeOptionsSelectButton}}" stepKey="selectOption2"/>
114+
<dontSeeElement selector="{{StorefrontProductInfoMainSection.tierPriceBlock}}" stepKey="dontSeeTierPriceBlock"/>
112115
</test>
113116
</tests>

app/code/Magento/ConfigurableProduct/view/frontend/web/js/configurable.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -740,21 +740,19 @@ define([
740740
* @private
741741
*/
742742
_displayTierPriceBlock: function (optionId) {
743-
var options, tierPriceHtml;
743+
var tierPrices = typeof optionId != 'undefined' && this.options.spConfig.optionPrices[optionId].tierPrices;
744744

745-
if (typeof optionId != 'undefined' &&
746-
this.options.spConfig.optionPrices[optionId].tierPrices != [] // eslint-disable-line eqeqeq
747-
) {
748-
options = this.options.spConfig.optionPrices[optionId];
745+
if (_.isArray(tierPrices) && tierPrices.length > 0) {
749746

750747
if (this.options.tierPriceTemplate) {
751-
tierPriceHtml = mageTemplate(this.options.tierPriceTemplate, {
752-
'tierPrices': options.tierPrices,
753-
'$t': $t,
754-
'currencyFormat': this.options.spConfig.currencyFormat,
755-
'priceUtils': priceUtils
756-
});
757-
$(this.options.tierPriceBlockSelector).html(tierPriceHtml).show();
748+
$(this.options.tierPriceBlockSelector).html(
749+
mageTemplate(this.options.tierPriceTemplate, {
750+
'tierPrices': tierPrices,
751+
'$t': $t,
752+
'currencyFormat': this.options.spConfig.currencyFormat,
753+
'priceUtils': priceUtils
754+
})
755+
).show();
758756
}
759757
} else {
760758
$(this.options.tierPriceBlockSelector).hide();

0 commit comments

Comments
 (0)