forked from alaguraj/odoo-testing-addons
: integrate Uber delivery fee logic and simplify checkout UI, and update docker-compose container naming conventions
This commit is contained in:
parent
264036f0de
commit
b4d292ac95
@ -2,7 +2,6 @@
|
|||||||
<odoo>
|
<odoo>
|
||||||
<!-- Display Uber fee in the total summary -->
|
<!-- Display Uber fee in the total summary -->
|
||||||
<template id="chennora_total_uber_display" inherit_id="website_sale.total" name="Chennora Total Uber Display">
|
<template id="chennora_total_uber_display" inherit_id="website_sale.total" name="Chennora Total Uber Display">
|
||||||
<!-- Add Uber Delivery Row without touching the existing Subtotal to avoid JS crashes -->
|
|
||||||
<xpath expr="//tr[@id='order_total_untaxed']" position="after">
|
<xpath expr="//tr[@id='order_total_untaxed']" position="after">
|
||||||
<t t-set="uber_line" t-value="website_sale_order.order_line.filtered(lambda l: l.product_id.name == 'Uber Delivery Fee')"/>
|
<t t-set="uber_line" t-value="website_sale_order.order_line.filtered(lambda l: l.product_id.name == 'Uber Delivery Fee')"/>
|
||||||
<tr t-if="uber_line" id="uber_delivery_row">
|
<tr t-if="uber_line" id="uber_delivery_row">
|
||||||
@ -14,16 +13,26 @@
|
|||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- Hide the Uber fee from the standard product list in the sidebar -->
|
<!-- Hide Uber fee from cart summary items -->
|
||||||
<template id="chennora_cart_summary_uber_hide" inherit_id="website_sale.checkout_layout" name="Chennora Cart Summary Uber Hide">
|
<template id="chennora_cart_summary_uber_hide" inherit_id="website_sale.checkout_layout" name="Chennora Cart Summary Uber Hide">
|
||||||
<xpath expr="//table[@id='cart_products']//tr" position="attributes">
|
<xpath expr="//table[@id='cart_products']//tr" position="attributes">
|
||||||
<attribute name="t-if">line.product_id.name != 'Uber Delivery Fee'</attribute>
|
<attribute name="t-if">line.product_id.name != 'Uber Delivery Fee'</attribute>
|
||||||
</xpath>
|
</xpath>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- Custom Checkout Page Logic -->
|
<!-- Simplify Checkout: Show only Billing Address, Hide Shipping Address UI -->
|
||||||
<template id="chennora_checkout_custom" inherit_id="website_sale.checkout" name="Chennora Checkout Custom" priority="99">
|
<template id="chennora_checkout_custom" inherit_id="website_sale.checkout" name="Chennora Checkout Custom" priority="99">
|
||||||
<!-- Add error banner and script after the main Address header (safest anchor point) -->
|
<!-- Hide the Shipping column UI to simplify the page (avoids confusion) -->
|
||||||
|
<xpath expr="//div[h4[contains(., 'Shipping')]]" position="attributes">
|
||||||
|
<attribute name="style">display: none !important;</attribute>
|
||||||
|
</xpath>
|
||||||
|
|
||||||
|
<!-- Rename Billing to just 'Address' -->
|
||||||
|
<xpath expr="//h4[contains(., 'Billing')]" position="replace">
|
||||||
|
<h3 class="mb-4">Delivery Address</h3>
|
||||||
|
</xpath>
|
||||||
|
|
||||||
|
<!-- Script for Uber Quote using the primary partner address -->
|
||||||
<xpath expr="//h3" position="after">
|
<xpath expr="//h3" position="after">
|
||||||
<div id="uber_error" class="alert alert-danger d-none my-3" role="alert"></div>
|
<div id="uber_error" class="alert alert-danger d-none my-3" role="alert"></div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
@ -57,14 +66,14 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For delivery, disable by default to force check
|
|
||||||
disableButton();
|
disableButton();
|
||||||
|
|
||||||
|
// Use Billing Address (Invoice) for Uber Quote
|
||||||
const addressData = {
|
const addressData = {
|
||||||
street: "<t t-esc='order.partner_shipping_id.street'/>",
|
street: "<t t-esc='order.partner_invoice_id.street'/>",
|
||||||
city: "<t t-esc='order.partner_shipping_id.city'/>",
|
city: "<t t-esc='order.partner_invoice_id.city'/>",
|
||||||
zip: "<t t-esc='order.partner_shipping_id.zip'/>",
|
zip: "<t t-esc='order.partner_invoice_id.zip'/>",
|
||||||
country: "<t t-esc='order.partner_shipping_id.country_id.name'/>"
|
country: "<t t-esc='order.partner_invoice_id.country_id.name'/>"
|
||||||
};
|
};
|
||||||
|
|
||||||
if (addressData.street && addressData.zip) {
|
if (addressData.street && addressData.zip) {
|
||||||
@ -73,11 +82,9 @@
|
|||||||
headers: {'Content-Type': 'application/json'},
|
headers: {'Content-Type': 'application/json'},
|
||||||
body: JSON.stringify({ params: { address_data: addressData } })
|
body: JSON.stringify({ params: { address_data: addressData } })
|
||||||
}).then(r => r.json()).then(data => {
|
}).then(r => r.json()).then(data => {
|
||||||
console.log("Uber: Result", data.result);
|
|
||||||
if (data.result && data.result.success) {
|
if (data.result && data.result.success) {
|
||||||
enableButton();
|
enableButton();
|
||||||
if (errorDiv) errorDiv.classList.add('d-none');
|
if (errorDiv) errorDiv.classList.add('d-none');
|
||||||
|
|
||||||
const hasFee = "<t t-esc="any(l.product_id.name == 'Uber Delivery Fee' for l in website_sale_order.order_line) and 'true' or 'false'"/>" === "true";
|
const hasFee = "<t t-esc="any(l.product_id.name == 'Uber Delivery Fee' for l in website_sale_order.order_line) and 'true' or 'false'"/>" === "true";
|
||||||
if (!hasFee && window.location.search.indexOf('quoted=1') === -1) {
|
if (!hasFee && window.location.search.indexOf('quoted=1') === -1) {
|
||||||
window.location.href = window.location.pathname + '?quoted=1';
|
window.location.href = window.location.pathname + '?quoted=1';
|
||||||
@ -90,17 +97,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).catch(err => {
|
}).catch(err => {
|
||||||
console.error("Uber Fetch error", err);
|
console.error("Uber error", err);
|
||||||
enableButton(); // Fallback
|
enableButton();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', initUberQuote); } else { initUberQuote(); }
|
||||||
if (document.readyState === 'loading') {
|
|
||||||
document.addEventListener('DOMContentLoaded', initUberQuote);
|
|
||||||
} else {
|
|
||||||
initUberQuote();
|
|
||||||
}
|
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
</xpath>
|
</xpath>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user