diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0f0e0750a7..9cd8be93a7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Use fetch when updating variants in cart [#2521](https://github.com/bigcommerce/cornerstone/pull/2521)
- Add a region to display the payment promotion widget on the category pages [#2530](https://github.com/bigcommerce/cornerstone/pull/2530)
- Rename the region to display the payment promotion widget on the category pages [#2531](https://github.com/bigcommerce/cornerstone/pull/2531)
+- Cornerstone update to support multiple date fields and remove blank space [#2533](https://github.com/bigcommerce/cornerstone/pull/2533)
## 6.15.0 (10-18-2024)
- Cornerstone changes to support inc/ex tax price lists on PDP [#2486](https://github.com/bigcommerce/cornerstone/pull/2486)
diff --git a/assets/js/theme/common/product-details.js b/assets/js/theme/common/product-details.js
index 7ef5c481cf..ce4d92f2f7 100644
--- a/assets/js/theme/common/product-details.js
+++ b/assets/js/theme/common/product-details.js
@@ -594,14 +594,13 @@ export default class ProductDetails extends ProductDetailsBase {
}
updateDateSelector() {
- $(document).ready(() => {
- const monthSelector = $('#month-selector');
- const daySelector = $('#day-selector');
- const yearSelector = $('#year-selector');
-
- const updateDays = () => {
- const month = parseInt(monthSelector.val(), 10);
- const year = parseInt(yearSelector.val(), 10);
+ this.$scope.each((i, scope) => {
+ function updateDays(dateOption) {
+ const monthSelector = dateOption.querySelector('select[name$="[month]"]');
+ const daySelector = dateOption.querySelector('select[name$="[day]"]');
+ const yearSelector = dateOption.querySelector('select[name$="[year]"]');
+ const month = parseInt(monthSelector.value, 10);
+ const year = parseInt(yearSelector.value, 10);
let daysInMonth;
if (!Number.isNaN(month) && !Number.isNaN(year)) {
@@ -616,17 +615,28 @@ export default class ProductDetails extends ProductDetailsBase {
daysInMonth = 31;
}
- daySelector.empty();
-
- for (let i = 1; i <= daysInMonth; i++) {
- daySelector.append($('').val(i).text(i));
+ for (let day = 29; day <= 31; day++) {
+ const option = daySelector.querySelector(`option[value="${day}"]`);
+ if (day <= daysInMonth && !option) {
+ daySelector.options.add(new Option(day, day));
+ } else if (day > daysInMonth && option) {
+ option.remove();
+ }
}
}
- };
+ }
+
+ $(scope).on('change', (e) => {
+ const dateOption = e.target && e.target.closest && e.target.closest('[data-product-attribute=date]');
- monthSelector.on('change', updateDays);
- yearSelector.on('change', updateDays);
- updateDays();
+ if (dateOption) {
+ updateDays(dateOption);
+ }
+ });
+
+ scope.querySelectorAll('[data-product-attribute=date]').forEach(dateOption => {
+ updateDays(dateOption);
+ });
});
}
}
diff --git a/templates/components/products/options/date.html b/templates/components/products/options/date.html
index 7972b2c2b1..9ae5c9f93b 100644
--- a/templates/components/products/options/date.html
+++ b/templates/components/products/options/date.html
@@ -4,7 +4,7 @@
{{> components/common/requireness-msg}}
-