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 <noreply@anthropic.com>
This commit is contained in:
parent
8b54145d9d
commit
04d09cfc4e
1 changed files with 2 additions and 2 deletions
|
|
@ -308,7 +308,7 @@ try {
|
||||||
'Name' => strlen(trim($itemName)) > 0 ? $itemName : $catName,
|
'Name' => strlen(trim($itemName)) > 0 ? $itemName : $catName,
|
||||||
'Description' => $row['Description'] ?? '',
|
'Description' => $row['Description'] ?? '',
|
||||||
'ParentItemID' => $effectiveParentID,
|
'ParentItemID' => $effectiveParentID,
|
||||||
'Price' => $row['Price'],
|
'Price' => (float) $row['Price'],
|
||||||
'IsActive' => (int) $row['IsActive'],
|
'IsActive' => (int) $row['IsActive'],
|
||||||
'IsCheckedByDefault' => (int) $row['IsCheckedByDefault'],
|
'IsCheckedByDefault' => (int) $row['IsCheckedByDefault'],
|
||||||
'RequiresChildSelection' => (int) $row['RequiresChildSelection'],
|
'RequiresChildSelection' => (int) $row['RequiresChildSelection'],
|
||||||
|
|
@ -368,7 +368,7 @@ try {
|
||||||
'ItemID' => (int) $opt['OptionItemID'],
|
'ItemID' => (int) $opt['OptionItemID'],
|
||||||
'Name' => $opt['OptionName'],
|
'Name' => $opt['OptionName'],
|
||||||
'Description' => $opt['OptionDescription'] ?? '',
|
'Description' => $opt['OptionDescription'] ?? '',
|
||||||
'Price' => $opt['OptionPrice'],
|
'Price' => (float) $opt['OptionPrice'],
|
||||||
'IsCheckedByDefault' => (int) $opt['OptionIsDefault'],
|
'IsCheckedByDefault' => (int) $opt['OptionIsDefault'],
|
||||||
'SortOrder' => (int) $opt['OptionSortOrder'],
|
'SortOrder' => (int) $opt['OptionSortOrder'],
|
||||||
];
|
];
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue