Magento Tier Pricing Issue on “Price as Configured” for Bundle Products
Hello developers,
I recently encountered an issue with Magento’s bundle product tier pricing functionality that I thought would be worth sharing and resolving here. Let me explain the problem in detail.
The Problem: Tier Pricing Not Applied to “Price as Configured”
Currently, when selecting an option from a bundle product’s checkbox selection, the “Price as Configured” updates with the full price of the selected item instead of applying the configured tier pricing logic. This happens even though the default quantity for the selection falls within the defined tier pricing range.
To understand this issue better, let me walk you through the relevant JavaScript code in /skin/frontend/base/default/js/bundle.js.
selectionPrice: function(optionId, selectionId) {
//................. (other code)
if (this.config.priceType == '0') {
price = this.config.options[optionId].selections[selectionId].price;
tierPrice = this.config.options[optionId].selections[SelectionId].tierPrice;
for (var i=0; i < tierPrice.length; i++) {
if (Number(tierPrice[i].price_qty) <= qty && Number(tierPrice[i].price) <= price) {
price = tierPrice[i].price;
}
}
} else {
//................. (other code)
}
}
As you can see, the script attempts to iterate through the tierPrice array and apply the appropriate pricing based on the quantity selected. However, this loop never executes as expected.
The Investigation
Upon closer inspection in the console, I discovered that while we can directly access individual tier prices using syntax like:
bundle.config.options['301'].selections['1066'].tierPrice['32000-5']
The Magento code relies on being able to call tierPrice[0] instead of tierPrice['32000-5'] for each tier. Unfortunately, calling tierPrice[0] returns undefined, and tierPrice.length also returns undefined. This appears to be the core issue causing the tier pricing logic to fail.
Potential Solutions
-
Review Tier Pricing Configuration: Ensure that your tier pricing configuration is set up correctly in the Magento admin panel. Double-check the quantity ranges and prices for each tier.
-
Inspect JavaScript Errors: Use browser development tools to monitor the console logs and network requests when interacting with bundle products. This may reveal additional errors or insights into the issue.
-
Contact Magento Support: If you’re using a paid version of Magento, consider reaching out to their technical support team for further assistance. They can provide more specific guidance tailored to your setup.
-
Check Custom Extensions/Overrides: If you have any custom extensions or overrides installed for bundle products, review them carefully as they might be interfering with the default tier pricing logic.
Conclusion
This issue appears to stem from a limitation in how Magento handles array indexing when retrieving tier price data. While I haven’t found a definitive solution yet, the key takeaways are:
- Ensure your tier pricing configuration is correct.
- Thoroughly inspect JavaScript errors and network requests for clues.
- Consider reaching out to official support or seeking help from experienced Magento developers.
If you’ve encountered similar issues or have additional insights to share, please don’t hesitate to comment below. We can learn a lot from each other’s experiences in the Magento community!
Stay coding!