implement custom checkout address form with delivery/pickup toggle and address field validation

This commit is contained in:
Alaguraj0361 2026-04-06 20:03:03 +05:30
parent 0b867b9315
commit 2a98fac10d

View File

@ -377,6 +377,46 @@
<!-- 3. Completely remove the "Shipping" section block --> <!-- 3. Completely remove the "Shipping" section block -->
<xpath expr="//t[@groups='account.group_delivery_invoice_address']" position="replace"/> <xpath expr="//t[@groups='account.group_delivery_invoice_address']" position="replace"/>
<!-- 4. UBER QUOTE RELOAD SCRIPT (Ensures fee is applied on page load) -->
<xpath expr="//h4" position="after">
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function() {
// Only run if the order is for delivery
const isDelivery = "<t t-esc='order.fulfilment_type'/>" === "delivery";
if (!isDelivery) return;
// Address data for re-calculating quote if needed
const addressData = {
street: "<t t-esc='order.partner_shipping_id.street'/>",
city: "<t t-esc='order.partner_shipping_id.city'/>",
zip: "<t t-esc='order.partner_shipping_id.zip'/>",
country: "<t t-esc='order.partner_shipping_id.country_id.name'/>"
};
if (addressData.street &amp;&amp; addressData.zip) {
fetch('/shop/uber/quote', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
params: { address_data: addressData }
})
}).then(r => r.json()).then(data => {
if (data.result &amp;&amp; data.result.success) {
// Refresh the summary if it changed (or just refresh the page once)
if (data.result.fee > 0) {
// Normally we would just update the UI, but Odoo summary is server-side
// reload once to show the fee in the sidebar
if (window.location.search.indexOf('quoted=1') === -1) {
window.location.href = window.location.pathname + '?quoted=1';
}
}
}
});
}
});
</script>
</xpath>
</template> </template>
<!-- 2. CART SUMMARY OVERRIDES FOR UBER --> <!-- 2. CART SUMMARY OVERRIDES FOR UBER -->
@ -409,52 +449,6 @@
</template> </template>
<!-- 4. UBER QUOTE ON REVIEW PAGE -->
<template id="chennora_checkout_review_uber" inherit_id="website_sale.checkout" name="Chennora Checkout Review Uber">
<xpath expr="//div[@id='wrap']" position="inside">
<script type="text/javascript">
document.addEventListener("DOMContentLoaded", function() {
// Only run if the order is for delivery
const isDelivery = "<t t-esc='website_sale_order.fulfilment_type'/>" === "delivery";
if (!isDelivery) return;
// Address data for re-calculating quote if needed
const addressData = {
street: "<t t-esc='website_sale_order.partner_shipping_id.street'/>",
city: "<t t-esc='website_sale_order.partner_shipping_id.city'/>",
zip: "<t t-esc='website_sale_order.partner_shipping_id.zip'/>",
country: "<t t-esc='website_sale_order.partner_shipping_id.country_id.name'/>"
};
if (addressData.street &amp;&amp; addressData.zip) {
fetch('/shop/uber/quote', {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
params: { address_data: addressData }
})
}).then(r => r.json()).then(data => {
if (data.result &amp;&amp; data.result.success) {
// Refresh the summary if it changed (or just refresh the page once)
if (data.result.fee > 0) {
// Normally we would just update the UI, but Odoo summary is server-side
// If we just added it to the cart, the page needs a refresh to show correctly
// But to avoid loops, only refresh if the amount was previously 0
const totalStr = document.querySelector('#amount_total_summary .oe_currency_value')?.innerText || '0';
const subtotalStr = document.querySelector('.monetary_field span')?.innerText || '0';
// Simple check: if summary doesn't seem to have the fee, refresh
// Better yet: just update the local UI? No, safest is to reload once.
if (window.location.search.indexOf('quoted=1') === -1) {
window.location.href = window.location.pathname + '?quoted=1';
}
}
}
});
}
});
</script>
</xpath>
</template>
<!-- Custom Wizard - Rename Shipping step to Billing safely without python errors --> <!-- Custom Wizard - Rename Shipping step to Billing safely without python errors -->
<template id="chennora_wizard_checkout_custom" inherit_id="website_sale.wizard_checkout" name="Chennora Wizard Custom" priority="99"> <template id="chennora_wizard_checkout_custom" inherit_id="website_sale.wizard_checkout" name="Chennora Wizard Custom" priority="99">