implement unified checkout address layout with fulfillment type selection and enhanced form validation
This commit is contained in:
parent
c6738e71d7
commit
3bc6298559
@ -153,7 +153,7 @@
|
||||
});
|
||||
|
||||
// 3. Custom Validation on Submit
|
||||
if (submitBtn) {
|
||||
if (submitBtn && document.querySelector('form.checkout_autoformat')) {
|
||||
submitBtn.addEventListener('click', function(e) {
|
||||
const form = document.querySelector('form.checkout_autoformat');
|
||||
if (!form) return;
|
||||
@ -239,6 +239,8 @@
|
||||
containers.forEach(c => {
|
||||
c.querySelectorAll('input, select').forEach(i => i.removeAttribute('required'));
|
||||
});
|
||||
// Safety: Always enable button for pickup
|
||||
if (submitBtn) submitBtn.disabled = false;
|
||||
} else {
|
||||
containers.forEach(c => c.style.display = '');
|
||||
if (addrHeader) addrHeader.style.display = '';
|
||||
@ -295,7 +297,7 @@
|
||||
Uber Delivery Fee: $${data.result.fee} (Distance Based)
|
||||
</div>
|
||||
</div>`;
|
||||
if (submitBtn) submitBtn.disabled = false;
|
||||
if (submitBtn && document.querySelector('input[name="street"]')) submitBtn.disabled = false;
|
||||
} else {
|
||||
msgDiv.className = 'alert alert-danger my-3 animated fadeIn';
|
||||
msgDiv.style.display = '';
|
||||
@ -306,7 +308,7 @@
|
||||
${data.result?.error || "This specific address is outside the Uber delivery radius."}
|
||||
</div>
|
||||
</div>`;
|
||||
if (submitBtn) submitBtn.disabled = true;
|
||||
if (submitBtn && document.querySelector('input[name="street"]')) submitBtn.disabled = true;
|
||||
}
|
||||
}).catch(err => {
|
||||
console.error("Uber API Error:", err);
|
||||
@ -409,7 +411,7 @@
|
||||
} else {
|
||||
msgBox.className = 'alert alert-danger my-3';
|
||||
msgBox.innerHTML = `<strong>✕ Uber Direct: Invalid Operation</strong><br/>${data.result?.error || "Outside delivery radius."}`;
|
||||
document.querySelector('button[type="submit"]')?.setAttribute('disabled', 'disabled');
|
||||
if (billingGrid) document.querySelector('button[type="submit"]')?.setAttribute('disabled', 'disabled');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user