Skip to content

CSS for tier prices block still visible when there are no tier prices #29194

Closed
@posidonius

Description

@posidonius

#26081

Preconditions (*)

Magento 2.4

Steps to reproduce (*)

  1. Create a configurable product and associate 1 simple product with no tier pricing and 1 simple product with tier pricing
  2. Style the tier prices block with a background or border (for example border: aqua; background: #99cfff;)
  3. Toggle between the 2 simple products. For the product with no tier pricing, the content disappears but the CSS styling remains (e.g. in Magento Blank theme, there is an empty box with a gray background).

Screenshot_46
Screenshot_47

Expected result (*)

  1. The tier price block, including associated CSS, should disappear from the frontend when choosing a simple product that doesn't have tier prices.

Actual result (*)

  1. The tier price block, including CSS styling such as background or border, is visible even when there are no tier prices to display.
    Screenshot_47

Additional information
Even when there are no tier prices, any CSS applied to tier prices block are visible on the frontend.

A simple edit to _displayTierPriceBlock function in configurable.js can fix this problem.
Solution:

in _displayTierPriceBlock function of configurable.js, change the following if statement:

            if (typeof optionId != 'undefined' &&
                this.options.spConfig.optionPrices[optionId].tierPrices != [] // eslint-disable-line eqeqeq
            ) 

to the following, which includes a check for tier prices array with 0 length:

            if (typeof optionId != 'undefined' &&
                this.options.spConfig.optionPrices[optionId].tierPrices != [] && // eslint-disable-line eqeqeq
                this.options.spConfig.optionPrices[optionId].tierPrices.length > 0
            ) 

  • [S4 ] Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.

Metadata

Metadata

Assignees

Labels

Component: ConfigurableProductComponent: CssFixed in 2.4.xThe issue has been fixed in 2.4-develop branchIssue: Clear DescriptionGate 2 Passed. Manual verification of the issue description passedIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedIssue: Format is validGate 1 Passed. Automatic verification of issue format passedIssue: Ready for WorkGate 4. Acknowledged. Issue is added to backlog and ready for developmentPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: doneReported on 2.4.0Indicates original Magento version for the Issue report.Reproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S2Major restrictions or short-term circumventions are required until a fix is available.Triage: DoneHas been reviewed and prioritized during Triage with Product Managers

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions