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 2, 2023
1 parent 87b6d81 commit b3f8e2b
Show file tree
Hide file tree
Showing 21 changed files with 29 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 outOfStockDefaultMessage = this.context.outOfStockDefaultMessage;
let outOfStockMessage = data.out_of_stock_message;

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

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

$('[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
1 change: 1 addition & 0 deletions lang/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@
"shipping_free": "Gratis fragt",
"shipping_calculated": "Beregnes ved kassen",
"sold_out": "Udsolgt",
"out_of_stock_default_message": "Udsolgt",
"pre_order": "Forudbestil nu",
"choose_options": "Vælg valgmuligheder",
"quick_view": "Hurtig visning",
Expand Down
1 change: 1 addition & 0 deletions lang/de.json
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@
"shipping_free": "Kostenloser Versand",
"shipping_calculated": "Wird beim Bezahlvorgang berechnet",
"sold_out": "Ausverkauft",
"out_of_stock_default_message": "Ausverkauft",
"pre_order": "Jetzt vorbestellen",
"choose_options": "Optionen auswählen",
"quick_view": "Schnellansicht",
Expand Down
1 change: 1 addition & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,7 @@
"shipping_free": "Free Shipping",
"shipping_calculated": "Calculated at Checkout",
"sold_out": "Sold Out",
"out_of_stock_default_message": "Sold Out",
"pre_order": "Pre-Order Now",
"choose_options": "Choose Options",
"quick_view": "Quick view",
Expand Down
1 change: 1 addition & 0 deletions lang/es-419.json
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@
"shipping_free": "Envío gratuito",
"shipping_calculated": "Calculado en el proceso de pago",
"sold_out": "Agotado",
"out_of_stock_default_message": "Agotado",
"pre_order": "Reserva ahora",
"choose_options": "Elegir opciones",
"quick_view": "Vista rápida",
Expand Down
1 change: 1 addition & 0 deletions lang/es-AR.json
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@
"shipping_free": "Envío gratuito",
"shipping_calculated": "Calculado en el proceso de pago",
"sold_out": "Agotado",
"out_of_stock_default_message": "Agotado",
"pre_order": "Reserva ahora",
"choose_options": "Elegir opciones",
"quick_view": "Vista rápida",
Expand Down
1 change: 1 addition & 0 deletions lang/es-CL.json
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@
"shipping_free": "Envío gratuito",
"shipping_calculated": "Calculado en el proceso de pago",
"sold_out": "Agotado",
"out_of_stock_default_message": "Agotado",
"pre_order": "Reserva ahora",
"choose_options": "Elegir opciones",
"quick_view": "Vista rápida",
Expand Down
1 change: 1 addition & 0 deletions lang/es-CO.json
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@
"shipping_free": "Envío gratuito",
"shipping_calculated": "Calculado en el proceso de pago",
"sold_out": "Agotado",
"out_of_stock_default_message": "Agotado",
"pre_order": "Reserva ahora",
"choose_options": "Elegir opciones",
"quick_view": "Vista rápida",
Expand Down
1 change: 1 addition & 0 deletions lang/es-LA.json
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@
"shipping_free": "Envío gratuito",
"shipping_calculated": "Calculado en el proceso de pago",
"sold_out": "Agotado",
"out_of_stock_default_message": "Agotado",
"pre_order": "Reserva ahora",
"choose_options": "Elegir opciones",
"quick_view": "Vista rápida",
Expand Down
1 change: 1 addition & 0 deletions lang/es-MX.json
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@
"shipping_free": "Envío gratuito",
"shipping_calculated": "Calculado en el proceso de pago",
"sold_out": "Agotado",
"out_of_stock_default_message": "Agotado",
"pre_order": "Reserva ahora",
"choose_options": "Elegir opciones",
"quick_view": "Vista rápida",
Expand Down
1 change: 1 addition & 0 deletions lang/es-PE.json
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@
"shipping_free": "Envío gratuito",
"shipping_calculated": "Calculado en el proceso de pago",
"sold_out": "Agotado",
"out_of_stock_default_message": "Agotado",
"pre_order": "Reserva ahora",
"choose_options": "Elegir opciones",
"quick_view": "Vista rápida",
Expand Down
1 change: 1 addition & 0 deletions lang/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@
"shipping_free": "Envío gratis",
"shipping_calculated": "Se calcula durante el proceso de pago",
"sold_out": "Agotado",
"out_of_stock_default_message": "Agotado",
"pre_order": "Realizar pedido de preventa ahora",
"choose_options": "Elegir opciones",
"quick_view": "Vista rápida",
Expand Down
1 change: 1 addition & 0 deletions lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@
"shipping_free": "Livraison gratuite",
"shipping_calculated": "Calculés au moment du paiement",
"sold_out": "Épuisé",
"out_of_stock_default_message": "Épuisé",
"pre_order": "Précommander maintenant",
"choose_options": "Choisir les options",
"quick_view": "Aperçu rapide",
Expand Down
1 change: 1 addition & 0 deletions lang/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@
"shipping_free": "Spedizione gratuita",
"shipping_calculated": "Calcolato al momento del checkout",
"sold_out": "Esaurito",
"out_of_stock_default_message": "Esaurito",
"pre_order": "Pre-ordina ora",
"choose_options": "Scegli opzioni",
"quick_view": "Visualizzazione rapida",
Expand Down
1 change: 1 addition & 0 deletions lang/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@
"shipping_free": "Gratis verzending",
"shipping_calculated": "Berekend tijdens het afrekenen",
"sold_out": "Uitverkocht",
"out_of_stock_default_message": "Uitverkocht",
"pre_order": "Nu vooruitbestellen",
"choose_options": "Opties kiezen",
"quick_view": "Snelle weergave",
Expand Down
1 change: 1 addition & 0 deletions lang/no.json
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@
"shipping_free": "Gratis frakt",
"shipping_calculated": "Regnes ut i kassen",
"sold_out": "Utsolgt",
"out_of_stock_default_message": "Utsolgt",
"pre_order": "Forhåndsbestill nå",
"choose_options": "Velg alternativer",
"quick_view": "Hurtigvisning",
Expand Down
1 change: 1 addition & 0 deletions lang/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@
"shipping_free": "Frete grátis",
"shipping_calculated": "Calculado na finalização da compra",
"sold_out": "Sair",
"out_of_stock_default_message": "Sair",
"pre_order": "Pré-encomendar agora",
"choose_options": "Selecionar opções",
"quick_view": "Exibição rápida",
Expand Down
1 change: 1 addition & 0 deletions lang/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@
"shipping_free": "Frete grátis",
"shipping_calculated": "Calculado na finalização da compra",
"sold_out": "Sair",
"out_of_stock_default_message": "Sair",
"pre_order": "Pré-encomendar agora",
"choose_options": "Selecionar opções",
"quick_view": "Exibição rápida",
Expand Down
1 change: 1 addition & 0 deletions lang/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@
"shipping_free": "Gratis frakt",
"shipping_calculated": "Beräknas vid kassan",
"sold_out": "Utsåld",
"out_of_stock_default_message": "Utsåld",
"pre_order": "Förbeställ nu",
"choose_options": "Välj alternativ",
"quick_view": "Snabbtitt",
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 'outOfStockDefaultMessage' (lang 'products.out_of_stock_default_message')}}

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

0 comments on commit b3f8e2b

Please sign in to comment.