implement unified checkout address layout with dynamic delivery/pickup selection and Uber delivery fee integration

This commit is contained in:
Alaguraj0361 2026-04-06 22:33:39 +05:30
parent d06d252b94
commit 0334bb324c

View File

@ -23,11 +23,17 @@
<!-- 3. MAIN FORM: Optimized Pickup/Delivery Layout --> <!-- 3. MAIN FORM: Optimized Pickup/Delivery Layout -->
<template id="chennora_address_unified" inherit_id="website_sale.address" name="Chennora Address Unified" priority="99"> <template id="chennora_address_unified" inherit_id="website_sale.address" name="Chennora Address Unified" priority="99">
<!-- Safely hide the 'Billing address' title --> <!-- Hide the 'Billing address' title -->
<xpath expr="//div[contains(@class, 'oe_cart')]//*[self::h2 or self::h3][1]" position="attributes"> <xpath expr="//div[contains(@class, 'oe_cart')]//*[self::h2 or self::h3][1]" position="attributes">
<attribute name="class" add="d-none" separator=" "/> <attribute name="class" add="d-none" separator=" "/>
</xpath> </xpath>
<!-- NEW: Hide the yellow 'Be aware' alert box -->
<xpath expr="//div[hasclass('alert-warning')][contains(., 'billing and shipping')]" position="attributes">
<attribute name="class" add="d-none" separator=" "/>
<attribute name="style">display: none !important;</attribute>
</xpath>
<!-- Inject Selection Cards --> <!-- Inject Selection Cards -->
<xpath expr="//form" position="before"> <xpath expr="//form" position="before">
<style> <style>
@ -87,22 +93,19 @@
const msgDiv = document.getElementById('uber_message'); const msgDiv = document.getElementById('uber_message');
const submitBtn = document.querySelector('button[type="submit"]') || document.querySelector('.btn-primary'); const submitBtn = document.querySelector('button[type="submit"]') || document.querySelector('.btn-primary');
// Select all address-related field containers for aggressive hiding
function getAddressContainers() { function getAddressContainers() {
const addressNames = ['street', 'street2', 'city', 'zip', 'country_id', 'state_id']; const addressNames = ['street', 'street2', 'city', 'zip', 'country_id', 'state_id'];
let containers = []; let containers = [];
addressNames.forEach(name => { addressNames.forEach(name => {
const input = document.querySelector(`[name="${name}"]`); const input = document.querySelector(`[name="${name}"]`);
if (input) { if (input) {
// Go up until we hit a col- or the parent with mb- class
const container = input.closest('div[class*="col-"]') || input.closest('.mb-3') || input.closest('.mb-4'); const container = input.closest('div[class*="col-"]') || input.closest('.mb-3') || input.closest('.mb-4');
if (container) containers.push(container); if (container) containers.push(container);
} }
}); });
return [...new Set(containers)]; // Unique containers return [...new Set(containers)];
} }
// Dynamic Address Header
let addrHeader = document.getElementById('dynamic_address_header'); let addrHeader = document.getElementById('dynamic_address_header');
if (!addrHeader &amp;&amp; document.querySelector('[name="street"]')) { if (!addrHeader &amp;&amp; document.querySelector('[name="street"]')) {
addrHeader = document.createElement('div'); addrHeader = document.createElement('div');
@ -162,11 +165,8 @@
}); });
} }
// Event handlers
const triggers = document.querySelectorAll('input[name="street"], input[name="zip"]'); const triggers = document.querySelectorAll('input[name="street"], input[name="zip"]');
triggers.forEach(t => t.addEventListener('blur', checkUber)); triggers.forEach(t => t.addEventListener('blur', checkUber));
// Force initial refresh
setOrderType('delivery'); setOrderType('delivery');
} }
if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', initUnifiedForm); else initUnifiedForm(); if (document.readyState === 'loading') document.addEventListener('DOMContentLoaded', initUnifiedForm); else initUnifiedForm();