Skip to content

Commit

Permalink
sync behaviour for add to cart and increments buttons with alert mess…
Browse files Browse the repository at this point in the history
…age appearance
  • Loading branch information
bc-alexsaiannyi committed Jan 28, 2025
1 parent 678a7fe commit 5f0d845
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions assets/js/theme/common/product-details-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@ export function optionChangeDecorator(areDefaultOptionsSet) {
return (err, response) => {
const attributesData = response.data || {};
const attributesContent = response.content || {};
const shouldAttributesBeUpdated = true;

this.updateProductAttributes(attributesData);
if (areDefaultOptionsSet) {
this.updateView(attributesData, attributesContent, true);
this.updateView(attributesData, attributesContent, shouldAttributesBeUpdated);
} else {
this.updateDefaultAttributesForOOS(attributesData);
this.updateDefaultAttributesForOOS(attributesData, shouldAttributesBeUpdated);
}
};
}
Expand Down Expand Up @@ -278,7 +279,7 @@ export default class ProductDetailsBase {
viewModel.stock.$input.text(data.stock);
}

this.updateDefaultAttributesForOOS(data);
this.updateDefaultAttributesForOOS(data, shouldMessageAppear);
this.updateWalletButtonsView(data);

// If Bulk Pricing rendered HTML is available
Expand Down Expand Up @@ -366,9 +367,9 @@ export default class ProductDetailsBase {
}
}

updateDefaultAttributesForOOS(data) {
updateDefaultAttributesForOOS(data, shouldUpdateAttributes) {
const viewModel = this.getViewModel(this.$scope);
if (!data.purchasable || !data.instock) {
if (shouldUpdateAttributes && (!data.purchasable || !data.instock)) {
viewModel.$addToCart.prop('disabled', true);
viewModel.$increments.prop('disabled', true);
} else {
Expand Down

0 comments on commit 5f0d845

Please sign in to comment.