From 04d09cfc4e773b8299347b416d9edc650bbf2f08 Mon Sep 17 00:00:00 2001 From: John Mizerek Date: Mon, 16 Mar 2026 17:24:57 -0700 Subject: [PATCH] Fix item prices returning as strings instead of floats in JSON MySQL PDO returns DECIMAL/FLOAT columns as strings, causing json_encode to emit them as JSON strings ("9.99") instead of numbers (9.99). Android's Gson Map parsing fails the as? Number cast on strings, defaulting to 0.0. Cast Price to (float) before building the response. Co-Authored-By: Claude Sonnet 4.6 --- api/menu/items.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/api/menu/items.php b/api/menu/items.php index 8e847f8..b42e175 100644 --- a/api/menu/items.php +++ b/api/menu/items.php @@ -308,7 +308,7 @@ try { 'Name' => strlen(trim($itemName)) > 0 ? $itemName : $catName, 'Description' => $row['Description'] ?? '', 'ParentItemID' => $effectiveParentID, - 'Price' => $row['Price'], + 'Price' => (float) $row['Price'], 'IsActive' => (int) $row['IsActive'], 'IsCheckedByDefault' => (int) $row['IsCheckedByDefault'], 'RequiresChildSelection' => (int) $row['RequiresChildSelection'], @@ -368,7 +368,7 @@ try { 'ItemID' => (int) $opt['OptionItemID'], 'Name' => $opt['OptionName'], 'Description' => $opt['OptionDescription'] ?? '', - 'Price' => $opt['OptionPrice'], + 'Price' => (float) $opt['OptionPrice'], 'IsCheckedByDefault' => (int) $opt['OptionIsDefault'], 'SortOrder' => (int) $opt['OptionSortOrder'], ];