Checkout Bug - Fixes
Checkout Bug - Fixes
bista_menmd_website/static/src/js/website_sale.js
- Consolidated two duplicate websiteSaleDelivery.include({...}) blocks into one (the duplication was silently causing Pick Up to be auto-selected instead of Ground).
- Fixed shipping-method default selection: Pick Up is now excluded from the "cheapest carrier" pool entirely, Ground/Priority selection logic restored and corrected.
- Added a trusted-click listener on the delivery carrier list that:
- Marks the order as having an explicit carrier selection (/shop/cart/mark_carrier_explicit), so the default-selection logic never overrides a real customer choice, even Pick Up.
- Reloads the page once Odoo's own carrier-assignment lifecycle hook (_handleCarrierUpdateResult) confirms the update actually completed, so the address display / grey-out (server-rendered) stays in sync in both directions.
- Added a trusted-click listener on saved address cards that submits the existing address-selection form and waits for Odoo's own request to finish (via ajaxComplete) before reloading, fixing the "selecting a saved address doesn't update the shipping line" bug.
- Known cleanup item: there may still be leftover console.log('[menmd] ...') / [menmd DEBUG] debug lines from troubleshooting sessions. Worth a manual scan before this goes to UAT.
bista_menmd_website/controllers/website_sale.py
- shop_payment_validate: now checks for cancel/error transaction states (previously only checked draft), so a genuinely declined card is redirected back to /shop/payment with a message instead of reaching the order confirmation page.
- shop_payment: surfaces z_payment_declined_message (set by the above) into the template context so the customer sees why they landed back on the payment form.
- update_cart_address: sets a new z_shipping_address_confirmed flag whenever a customer explicitly picks a shipping address, so the auto-reassign logic in checkout_values() (see main.py below) doesn't silently override it.
bista_menmd_website/controllers/main.py
- checkout_values (in WebsiteSaleCustom): added and not order.z_shipping_address_confirmed to the auto-reassign condition, so a customer's real address choice is never silently reverted to "most recently created delivery address."
- cold_chain_check: now also returns carrier_explicitly_selected, read by the JS default-selection logic to know whether to skip auto-selecting a carrier.
- Added mark_carrier_explicit route: sets z_carrier_explicitly_selected = True on the order whenever a customer makes a genuine (trusted) carrier click.
- A set_pickup_address route may still be present from an earlier approach that was superseded (display-only address, no write). It's unused/dead code at this point — safe to delete, or leave, doesn't affect behavior either way.
bista_menmd_customization/models/sale_order.py
- Added two new boolean fields to sale.order:
- z_shipping_address_confirmed
- z_carrier_explicitly_selected
bista_menmd_customization/models/delivery_carrier_ext.py (or wherever this model lives in your tree)
- Added z_is_pickup boolean field to delivery.carrier, used to identify the Pick Up carrier by data instead of matching on its display label/name.
bista_menmd_customization/views/delivery_view.xml
- Exposed z_is_pickup on the delivery carrier form view so it can be set from the backend. This needs to be checked True on the actual "Pick Up" carrier record in whichever environment this deploys to — it's a one-time manual data step, not something the migration does automatically.
bista_menmd_website/views/shop_checkout.xml
- The checkout_redesign template block is now commented out. See the callout below, this is important context for whoever reviews the PR.
Payment page template (the file with payment_page_heading, payment_token_data_script, etc. — confirm exact filename in your tree)
- Extended the existing payment_page_heading template to show a red alert with z_payment_declined_message when present, visible on both desktop and mobile.