| @@ -219,12 +219,16 @@ | ||
| 219 | 219 | $countryLists = Helper::getCountyIsoLists(); |
| 220 | 220 | |
| 221 | 221 | $other = __('Uncategorized', 'fluent-cart'); |
| 222 | 222 | $transformedData = $results->map(function ($item) use ($countryLists, $other) { |
| 223 | - $countryName = Arr::get($countryLists, $item->country, $other); | |
| 223 | + $countryCode = strtoupper((string)$item->country); | |
| 224 | + $isKnown = isset($countryLists[$countryCode]); | |
| 225 | + | |
| 226 | + // `name` is the translated label; the map matches on the locale-stable `country_code`. | |
| 224 | 227 | return [ |
| 225 | - 'name' => $countryName, | |
| 226 | - 'value' => (int)$item->value, | |
| 228 | + 'country_code' => $isKnown ? $countryCode : null, | |
| 229 | + 'name' => $isKnown ? $countryLists[$countryCode] : $other, | |
| 230 | + 'value' => (int)$item->value, | |
| 227 | 231 | ]; |
| 228 | 232 | })->toArray(); |
| 229 | 233 | |
| 230 | 234 | // sort by value |