Skip to content

Commit

Permalink
fix(storefront): BCTHEME-1184 form.serialize() ignores dropdown optio…
Browse files Browse the repository at this point in the history
…n elements that have the disabled attribute
  • Loading branch information
“bc-yevhenii-buliuk” committed Feb 1, 2023
1 parent 87b6d81 commit 9a26db9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Draft
- Remove xlink attributes on svg [#2322](https://github.com/bigcommerce/cornerstone/pull/2322)
- form.serialize() ignores dropdown option elements that have the disabled attribute [#2326](https://github.com/bigcommerce/cornerstone/pull/2326)

## 6.8.0 (01-26-2023)
- Add remote_api_scripts into cart/preview template to let GA3 snippet to fire the Product Added event, when clicking Add to cart button on Product detail page and rendering the response in popup. [#2281](https://github.com/bigcommerce/cornerstone/pull/2281)
Expand Down
11 changes: 8 additions & 3 deletions assets/js/theme/common/product-details-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,19 @@ export default class ProductDetailsBase {
updateProductAttributes(data) {
const behavior = data.out_of_stock_behavior;
const inStockIds = data.in_stock_attributes;
const outOfStockMessage = ` (${data.out_of_stock_message})`;
const stockMessage = this.context.stockMessage;
let outOfStockMessage = data.out_of_stock_message;

if (behavior !== 'hide_option' && behavior !== 'label_option') {
return;
}

if (outOfStockMessage) {
outOfStockMessage = ` (${outOfStockMessage})`;
} else {
outOfStockMessage = ` (${stockMessage})`;
}

$('[data-product-attribute-value]', this.$scope).each((i, attribute) => {
const $attribute = $(attribute);
const attrId = parseInt($attribute.data('productAttributeValue'), 10);
Expand Down Expand Up @@ -407,7 +414,6 @@ export default class ProductDetailsBase {
$select[0].selectedIndex = 0;
}
} else {
$attribute.attr('disabled', 'disabled');
$attribute.html($attribute.html().replace(outOfStockMessage, '') + outOfStockMessage);
}
}
Expand All @@ -416,7 +422,6 @@ export default class ProductDetailsBase {
if (behavior === 'hide_option') {
$attribute.toggleOption(true);
} else {
$attribute.prop('disabled', false);
$attribute.html($attribute.html().replace(outOfStockMessage, ''));
}
}
Expand Down
2 changes: 2 additions & 0 deletions templates/components/products/product-view.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{{inject 'stockMessage' (lang 'products.sold_out')}}

<div class="productView"
{{#if settings.data_tag_enabled}}
data-event-type="product"
Expand Down

0 comments on commit 9a26db9

Please sign in to comment.