From b3f8e2b6476737424eda181bee5b2c55840417bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cbc-yevhenii-buliuk=E2=80=9D?= <“yevhenii.buliuk@bigcommerce.com”> Date: Wed, 1 Feb 2023 13:18:23 +0200 Subject: [PATCH] fix(storefront): BCTHEME-1184 form.serialize() ignores dropdown option elements that have the disabled attribute --- CHANGELOG.md | 1 + assets/js/theme/common/product-details-base.js | 11 ++++++++--- lang/da.json | 1 + lang/de.json | 1 + lang/en.json | 1 + lang/es-419.json | 1 + lang/es-AR.json | 1 + lang/es-CL.json | 1 + lang/es-CO.json | 1 + lang/es-LA.json | 1 + lang/es-MX.json | 1 + lang/es-PE.json | 1 + lang/es.json | 1 + lang/fr.json | 1 + lang/it.json | 1 + lang/nl.json | 1 + lang/no.json | 1 + lang/pt-BR.json | 1 + lang/pt.json | 1 + lang/sv.json | 1 + templates/components/products/product-view.html | 2 ++ 21 files changed, 29 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e8b418a597..98dfb82210 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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) diff --git a/assets/js/theme/common/product-details-base.js b/assets/js/theme/common/product-details-base.js index 51f1337b42..6927d48046 100644 --- a/assets/js/theme/common/product-details-base.js +++ b/assets/js/theme/common/product-details-base.js @@ -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); @@ -407,7 +414,6 @@ export default class ProductDetailsBase { $select[0].selectedIndex = 0; } } else { - $attribute.attr('disabled', 'disabled'); $attribute.html($attribute.html().replace(outOfStockMessage, '') + outOfStockMessage); } } @@ -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, '')); } } diff --git a/lang/da.json b/lang/da.json index db4e621386..838ecd8d94 100644 --- a/lang/da.json +++ b/lang/da.json @@ -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", diff --git a/lang/de.json b/lang/de.json index 1bad3a63fa..d02b10edc2 100644 --- a/lang/de.json +++ b/lang/de.json @@ -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", diff --git a/lang/en.json b/lang/en.json index 719cde18e6..17df02612b 100755 --- a/lang/en.json +++ b/lang/en.json @@ -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", diff --git a/lang/es-419.json b/lang/es-419.json index e8bf56d660..ebcb730dbf 100644 --- a/lang/es-419.json +++ b/lang/es-419.json @@ -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", diff --git a/lang/es-AR.json b/lang/es-AR.json index e8bf56d660..ebcb730dbf 100644 --- a/lang/es-AR.json +++ b/lang/es-AR.json @@ -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", diff --git a/lang/es-CL.json b/lang/es-CL.json index e8bf56d660..ebcb730dbf 100644 --- a/lang/es-CL.json +++ b/lang/es-CL.json @@ -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", diff --git a/lang/es-CO.json b/lang/es-CO.json index e8bf56d660..ebcb730dbf 100644 --- a/lang/es-CO.json +++ b/lang/es-CO.json @@ -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", diff --git a/lang/es-LA.json b/lang/es-LA.json index e8bf56d660..ebcb730dbf 100644 --- a/lang/es-LA.json +++ b/lang/es-LA.json @@ -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", diff --git a/lang/es-MX.json b/lang/es-MX.json index e8bf56d660..ebcb730dbf 100644 --- a/lang/es-MX.json +++ b/lang/es-MX.json @@ -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", diff --git a/lang/es-PE.json b/lang/es-PE.json index e8bf56d660..ebcb730dbf 100644 --- a/lang/es-PE.json +++ b/lang/es-PE.json @@ -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", diff --git a/lang/es.json b/lang/es.json index eb39b73ba9..b9aef127ff 100644 --- a/lang/es.json +++ b/lang/es.json @@ -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", diff --git a/lang/fr.json b/lang/fr.json index fe936db5cf..affc100fb9 100644 --- a/lang/fr.json +++ b/lang/fr.json @@ -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", diff --git a/lang/it.json b/lang/it.json index 7ac41f2baf..cbfa0b0960 100644 --- a/lang/it.json +++ b/lang/it.json @@ -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", diff --git a/lang/nl.json b/lang/nl.json index 5b73be5e33..91ac3b1ac3 100644 --- a/lang/nl.json +++ b/lang/nl.json @@ -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", diff --git a/lang/no.json b/lang/no.json index 8b392d82a3..e8716ff4bc 100644 --- a/lang/no.json +++ b/lang/no.json @@ -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", diff --git a/lang/pt-BR.json b/lang/pt-BR.json index 47b31ecf15..6c0da3b7e7 100644 --- a/lang/pt-BR.json +++ b/lang/pt-BR.json @@ -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", diff --git a/lang/pt.json b/lang/pt.json index 47b31ecf15..6c0da3b7e7 100644 --- a/lang/pt.json +++ b/lang/pt.json @@ -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", diff --git a/lang/sv.json b/lang/sv.json index fa5085f863..6e7d53a7f4 100644 --- a/lang/sv.json +++ b/lang/sv.json @@ -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", diff --git a/templates/components/products/product-view.html b/templates/components/products/product-view.html index 90b3dc890b..9816e13c28 100644 --- a/templates/components/products/product-view.html +++ b/templates/components/products/product-view.html @@ -1,3 +1,5 @@ +{{inject 'outOfStockDefaultMessage' (lang 'products.out_of_stock_default_message')}} +