Smart bundle promotion: auto-replace individual services with bundle
When 3+ services are pre-selected from URL and 2+ are bundle components, automatically check the bundle and uncheck the individual items. Also triggers bundle uncheck logic after any URL pre-selection. Prevents showing bundle AND its individual services simultaneously. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
11e8fad4b1
commit
1633522e95
1 changed files with 28 additions and 0 deletions
|
|
@ -568,6 +568,34 @@ preSelect.forEach(function(slug) {
|
|||
var cb = document.querySelector('input[data-slug="' + slug + '"]');
|
||||
if (cb) cb.checked = true;
|
||||
});
|
||||
|
||||
// Smart bundle promotion: if 3+ individual federal services are selected,
|
||||
// replace them with the bundle (better value)
|
||||
if (preSelect.length >= 3) {
|
||||
var bundleCb = document.querySelector('input[data-slug="dot-full-compliance"]');
|
||||
if (bundleCb) {
|
||||
var bundleComponents = (bundleCb.dataset.bundle || "").split(",");
|
||||
var selectedInBundle = preSelect.filter(function(s) { return bundleComponents.indexOf(s) >= 0; });
|
||||
if (selectedInBundle.length >= 2) {
|
||||
bundleCb.checked = true;
|
||||
// Uncheck the individual components the bundle covers
|
||||
bundleComponents.forEach(function(slug) {
|
||||
var cb = document.querySelector('input[data-slug="' + slug + '"]');
|
||||
if (cb) cb.checked = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// After pre-selection, trigger bundle uncheck logic for any checked bundles
|
||||
document.querySelectorAll("input[data-bundle]:checked").forEach(function(bundleCb) {
|
||||
var components = (bundleCb.dataset.bundle || "").split(",");
|
||||
components.forEach(function(slug) {
|
||||
var cb = document.querySelector('input[data-slug="' + slug + '"]');
|
||||
if (cb && cb.checked) cb.checked = false;
|
||||
});
|
||||
});
|
||||
|
||||
if (preSelect.length) updateTotal();
|
||||
|
||||
// Submit
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue