-
-
Notifications
You must be signed in to change notification settings - Fork 451
Fix wrong tier price displayed when some tier prices are higher than special price #5117
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
base: main
Are you sure you want to change the base?
Conversation
Added a check to skip tier prices that are greater than or equal to the final price.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a tier price display bug where incorrect tier prices are shown when some tier prices are higher than a product's special price. The root cause is an index mismatch between HTML-rendered tier price elements and the JavaScript tier price array used for dynamic price updates.
Key Changes:
- Added filtering logic to skip tier prices that are greater than or equal to the final price in the JavaScript configuration
- Ensures the JavaScript
tierPricesarray indices align with the CSS class indices (.tier-0,.tier-1, etc.) of the rendered HTML elements
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Test Results914 tests 903 ✅ 16s ⏱️ Results for commit 653518f. ♻️ This comment has been updated with latest results. |
|



Description (*)
This PR fixes a bug where tier prices display incorrect values when a product has a special price that is lower than some tier prices.
The Problem:
When a product has tier prices configured and a special price is set, two different filtering mechanisms are applied:
HTML rendering (
Mage_Catalog_Block_Product_Abstract::getTierPrices()): Only tier prices lower than the final price are rendered in HTML. Each rendered tier gets a sequential CSS class (.tier-0,.tier-1, etc.)JavaScript config (
Mage_Catalog_Helper_Product_Type_Composite::prepareJsonProductConfig()): ThetierPricesarray is built from ALL tier prices (via$product->getTierPrice()), regardless of whether they are greater than the special price.This causes an index mismatch between the HTML elements and the JavaScript array.
Example:
.tier-0in HTML).tier-1in HTML)The JavaScript
tierPricesarray contains 3 elements [diff0, diff1, diff2], but HTML only has 2 elements with classes.tier-0and.tier-1.When the JS tries to update
.tier-1usingtierPrices[1], it applies the wrong tier price difference (from the hidden tier instead of the third tier).The Fix:
Added filtering in
prepareJsonProductConfig()to skip tier prices that are greater than or equal to the final price, maintaining consistency with the HTML filtering logic.Related Pull Requests
Fixed Issues (if relevant)
Manual testing scenarios (*)
Questions or comments
The same filtering logic from
Mage_Catalog_Block_Product_Abstract::getTierPrices()(line 416) is now applied in the helper to ensure the JS array indices match the rendered HTML elements.Contribution checklist (*)