Skip to content

Commit da20c4e

Browse files
committed
ACP2E-2308: [CLOUD]: Configurable product with drop down attribute throws unexpected exception error and does not allow selection when a product carousel is present on PDP
1 parent 2b3ad2e commit da20c4e

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

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

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ define([
2222
options: {
2323
superSelector: '.super-attribute-select',
2424
selectSimpleProduct: '[name="selected_configurable_option"]',
25+
26+
/**
27+
* @deprecated Not used anymore
28+
* @see selectorProductPrice
29+
*/
2530
priceHolderSelector: '.price-box',
2631
spConfig: {},
2732
state: {},
@@ -86,7 +91,7 @@ define([
8691
_initializeOptions: function () {
8792
var options = this.options,
8893
gallery = $(options.mediaGallerySelector),
89-
priceBoxOptions = $(this.options.priceHolderSelector).priceBox('option').priceConfig || null;
94+
priceBoxOptions = this._getPriceBoxElement().priceBox('option').priceConfig || null;
9095

9196
if (priceBoxOptions && priceBoxOptions.optionTemplate) {
9297
options.optionTemplate = priceBoxOptions.optionTemplate;
@@ -100,7 +105,7 @@ define([
100105

101106
options.settings = options.spConfig.containerId ?
102107
$(options.spConfig.containerId).find(options.superSelector) :
103-
$(options.superSelector);
108+
this.element.parents(this.options.selectorProduct).find(options.superSelector);
104109

105110
options.values = options.spConfig.defaultValues || {};
106111
options.parentImage = $('[data-role=base-image-container] img').attr('src');
@@ -580,7 +585,7 @@ define([
580585
* configurable product's option selections.
581586
*/
582587
_reloadPrice: function () {
583-
$(this.options.priceHolderSelector).trigger('updatePrice', this._getPrices());
588+
this._getPriceBoxElement().trigger('updatePrice', this._getPrices());
584589
},
585590

586591
/**
@@ -654,7 +659,7 @@ define([
654659
* @private
655660
*/
656661
_calculatePrice: function (config) {
657-
var displayPrices = $(this.options.priceHolderSelector).priceBox('option').prices,
662+
var displayPrices = this._getPriceBoxElement().priceBox('option').prices,
658663
newPrices = this.options.spConfig.optionPrices[_.first(config.allowedProducts)] || {};
659664

660665
_.each(displayPrices, function (price, code) {
@@ -702,8 +707,7 @@ define([
702707
*/
703708
_displayRegularPriceBlock: function (optionId) {
704709
var shouldBeShown = true,
705-
$priceBox = this.element.parents(this.options.selectorProduct)
706-
.find(this.options.selectorProductPrice);
710+
$priceBox = this._getPriceBoxElement();
707711

708712
_.each(this.options.settings, function (element) {
709713
if (element.value === '') {
@@ -785,6 +789,18 @@ define([
785789
} else {
786790
$(this.options.tierPriceBlockSelector).hide();
787791
}
792+
},
793+
794+
/**
795+
* Returns the price container element
796+
*
797+
* @returns {*}
798+
* @private
799+
*/
800+
_getPriceBoxElement: function () {
801+
return this.element
802+
.parents(this.options.selectorProduct)
803+
.find(this.options.selectorProductPrice);
788804
}
789805
});
790806

app/code/Magento/Swatches/view/base/web/js/swatch-renderer.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ define([
280280
// tier prise selectors end
281281

282282
// A price label selector
283-
normalPriceLabelSelector: '.product-info-main .normal-price .price-label',
283+
normalPriceLabelSelector: '.normal-price .price-label',
284284
qtyInfo: '#qty'
285285
},
286286

@@ -1039,18 +1039,18 @@ define([
10391039
$(this.options.tierPriceBlockSelector).hide();
10401040
}
10411041

1042-
$(this.options.normalPriceLabelSelector).hide();
1042+
$product.find(this.options.normalPriceLabelSelector).hide();
10431043

1044-
_.each($('.' + this.options.classes.attributeOptionsWrapper), function (attribute) {
1044+
_.each(this.element.find('.' + this.options.classes.attributeOptionsWrapper), function (attribute) {
10451045
if ($(attribute).find('.' + this.options.classes.optionClass + '.selected').length === 0) {
10461046
if ($(attribute).find('.' + this.options.classes.selectClass).length > 0) {
10471047
_.each($(attribute).find('.' + this.options.classes.selectClass), function (dropdown) {
10481048
if ($(dropdown).val() === '0') {
1049-
$(this.options.normalPriceLabelSelector).show();
1049+
$product.find(this.options.normalPriceLabelSelector).show();
10501050
}
10511051
}.bind(this));
10521052
} else {
1053-
$(this.options.normalPriceLabelSelector).show();
1053+
$product.find(this.options.normalPriceLabelSelector).show();
10541054
}
10551055
}
10561056
}.bind(this));

0 commit comments

Comments
 (0)