Closed
Description
Preconditions (*)
- Magento 2.3.5
Steps to reproduce (*)
- Create a configurable product with swatch options
- Add tier prices to one of the options
- Go to configurable product PDP
- Select the tier price product
- Add the product to cart
- Click on edit button from mini cart/ cart page
- Check the tier price is not shown on edit product page
- Load the page with #attribute_id=value_id to preset the swatch value
Expected result (*)
- Tier price block should show
Actual result (*)
- Tier price does not show
Solution (*)
The issue lies in file;
/vendor/magento/module-swatches/view/base/web/js/swatch-renderer.js
The function _UpdatePrice: function () { has a dependency on if this.options.tierPriceTemplate being defined on hashed options being set on load, which it isnt.
Here's the change to ensure it gets defined;
Before:
_UpdatePrice: function () {
var $widget = this,
$product = $widget.element.parents($widget.options.selectorProduct),
$productPrice = $product.find(this.options.selectorProductPrice),
result = $widget._getNewPrices(),
tierPriceHtml,
isShow;
$productPrice.trigger(
'updatePrice',
{
'prices': $widget._getPrices(result, $productPrice.priceBox('option').prices)
}
);
isShow = typeof result != 'undefined' && result.oldPrice.amount !== result.finalPrice.amount;
$product.find(this.options.slyOldPriceSelector)[isShow ? 'show' : 'hide']();
if (typeof result != 'undefined' && result.tierPrices && result.tierPrices.length) {
if (this.options.tierPriceTemplate) {
tierPriceHtml = mageTemplate(
this.options.tierPriceTemplate,
{
'tierPrices': result.tierPrices,
'$t': $t,
'currencyFormat': this.options.jsonConfig.currencyFormat,
'priceUtils': priceUtils
}
);
$(this.options.tierPriceBlockSelector).html(tierPriceHtml).show();
}
After;
_UpdatePrice: function () {
var $widget = this,
$product = $widget.element.parents($widget.options.selectorProduct),
$productPrice = $product.find(this.options.selectorProductPrice),
result = $widget._getNewPrices(),
tierPriceHtml,
isShow;
$productPrice.trigger(
'updatePrice',
{
'prices': $widget._getPrices(result, $productPrice.priceBox('option').prices)
}
);
isShow = typeof result != 'undefined' && result.oldPrice.amount !== result.finalPrice.amount;
$product.find(this.options.slyOldPriceSelector)[isShow ? 'show' : 'hide']();
if (typeof result != 'undefined' && result.tierPrices && result.tierPrices.length) {
// ADDED HERE
if (this.options.tierPriceTemplate = $(this.options.tierPriceTemplateSelector).html()) {
tierPriceHtml = mageTemplate(
this.options.tierPriceTemplate,
{
'tierPrices': result.tierPrices,
'$t': $t,
'currencyFormat': this.options.jsonConfig.currencyFormat,
'priceUtils': priceUtils
}
);
$(this.options.tierPriceBlockSelector).html(tierPriceHtml).show();
}
Additional information
more detailed steps and screens #28270 (Comment)
Metadata
Metadata
Assignees
Labels
The issue has been fixed in 2.4-develop branchGate 2 Passed. Manual verification of the issue description passedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedGate 1 Passed. Automatic verification of issue format passedGate 4. Acknowledged. Issue is added to backlog and ready for developmentMay be fixed according to the position in the backlog.Indicates original Magento version for the Issue report.The issue has been reproduced on latest 2.4-develop branchAffects non-critical data or functionality and does not force users to employ a workaround.Has been reviewed and prioritized during Triage with Product Managers
Type
Projects
Status
Done