Skip to content

Commit

Permalink
fix(catalog): CATALOG-3085 refrain from updating the price shown on
Browse files Browse the repository at this point in the history
    quickview by default when the modal is rendered unless theres an
    actual default selection to be made.
  • Loading branch information
Ziad Abdo committed Apr 9, 2018
1 parent 3de6916 commit d0aef67
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Draft
- Add representation for products and variants with retail price that has sale price. [#1195](https://github.com/bigcommerce/cornerstone/pull/1195)
- Fix but in quickview related to grabbing default prices for products with no default selection. [#1197](https://github.com/bigcommerce/cornerstone/pull/1197)

## 1.15.0 (2018-04-04)
- Fix image dimensions on AMP pages. [#1192](https://github.com/bigcommerce/cornerstone/pull/1192)
Expand Down
24 changes: 17 additions & 7 deletions assets/js/theme/common/product-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ export default class ProductDetails {
const attributesData = response.data || {};
const attributesContent = response.content || {};
this.updateProductAttributes(attributesData);
this.updateView(attributesData, attributesContent);
if (hasDefaultOptions) {
this.updateView(attributesData, attributesContent);
} else {
this.updateDefaultAttributesForOOS(attributesData);
}
});
} else {
this.updateProductAttributes(productAttributesData);
Expand Down Expand Up @@ -443,19 +447,25 @@ export default class ProductDetails {
viewModel.stock.$input.text(data.stock);
}

this.updateDefaultAttributesForOOS(data);

// If Bulk Pricing rendered HTML is available
if (data.bulk_discount_rates && content) {
viewModel.$bulkPricing.html(content);
} else if (typeof (data.bulk_discount_rates) !== 'undefined') {
viewModel.$bulkPricing.html('');
}
}

updateDefaultAttributesForOOS(data) {
const viewModel = this.getViewModel(this.$scope);
if (!data.purchasable || !data.instock) {
viewModel.$addToCart.prop('disabled', true);
viewModel.$increments.prop('disabled', true);
} else {
viewModel.$addToCart.prop('disabled', false);
viewModel.$increments.prop('disabled', false);
}
// If Bulk Pricing rendered HTML is available
if (data.bulk_discount_rates && content) {
viewModel.$bulkPricing.html(content);
} else if (typeof (data.bulk_discount_rates) !== 'undefined') {
viewModel.$bulkPricing.html('');
}
}

/**
Expand Down

0 comments on commit d0aef67

Please sign in to comment.