From 9ebcd0b223d95ff781b7a2c27db0171d58e78787 Mon Sep 17 00:00:00 2001 From: John Mizerek Date: Tue, 13 Jan 2026 11:06:36 -0800 Subject: [PATCH] Fix businessId for delivery/takeaway orders Use cart's businessId when appState doesn't have one (e.g., when ordering without beacon detection). Co-Authored-By: Claude Opus 4.5 --- lib/screens/cart_view_screen.dart | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/screens/cart_view_screen.dart b/lib/screens/cart_view_screen.dart index be6c29a..aced334 100644 --- a/lib/screens/cart_view_screen.dart +++ b/lib/screens/cart_view_screen.dart @@ -326,9 +326,20 @@ class _CartViewScreenState extends State { final appState = context.read(); final cartOrderId = appState.cartOrderId; - final businessId = appState.selectedBusinessId; + // Use cart's businessId if appState doesn't have one (delivery/takeaway without beacon) + final businessId = appState.selectedBusinessId ?? _cart!.businessId; - if (cartOrderId == null || businessId == null) return; + if (cartOrderId == null || businessId <= 0) { + ScaffoldMessenger.of(context).showSnackBar( + SnackBar( + content: const Text("Error: Missing order or business information", style: TextStyle(color: Colors.black)), + backgroundColor: const Color(0xFF90EE90), + behavior: SnackBarBehavior.floating, + margin: const EdgeInsets.only(bottom: 80, left: 16, right: 16), + ), + ); + return; + } // Ensure order type is selected for delivery/takeaway orders if (_needsOrderTypeSelection && _selectedOrderType == null) {