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 <noreply@anthropic.com>
This commit is contained in:
parent
ef8421c88a
commit
9ebcd0b223
1 changed files with 13 additions and 2 deletions
|
|
@ -326,9 +326,20 @@ class _CartViewScreenState extends State<CartViewScreen> {
|
||||||
|
|
||||||
final appState = context.read<AppState>();
|
final appState = context.read<AppState>();
|
||||||
final cartOrderId = appState.cartOrderId;
|
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
|
// Ensure order type is selected for delivery/takeaway orders
|
||||||
if (_needsOrderTypeSelection && _selectedOrderType == null) {
|
if (_needsOrderTypeSelection && _selectedOrderType == null) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue