Fix UPS tracking errors when there's only one status entry (their API sucks)
This commit is contained in:
parent
55f0842b60
commit
ba8061f806
@ -93,7 +93,12 @@ class Tracking_UPS {
|
||||
$info->setCarrierLogo(CarrierAssets::getLogo(Carriers::getCarrierCode($info->getCarrier())));
|
||||
|
||||
if (count($trackinfo["Package"]["Activity"]) > 0) {
|
||||
$current = $trackinfo["Package"]["Activity"][0];
|
||||
// If there's only one entry, it might not be an array
|
||||
if (isset($trackinfo["Package"]["Activity"][0])) {
|
||||
$current = $trackinfo["Package"]["Activity"][0];
|
||||
} else {
|
||||
$current = $trackinfo["Package"]["Activity"];
|
||||
}
|
||||
$current_status = new TrackingEntry(
|
||||
TrackingStatus::UPSEventTypeToStatus($current["Status"]["Type"]),
|
||||
$current["Status"]["Description"] ?? "Unknown",
|
||||
@ -131,6 +136,12 @@ class Tracking_UPS {
|
||||
//
|
||||
// $info->setFrom($from);
|
||||
|
||||
// Only one entry, so put it in itself so the loop works
|
||||
if (!isset($trackinfo["Package"]["Activity"][0])) {
|
||||
$trackinfo["Package"]["Activity"] = [
|
||||
$trackinfo["Package"]["Activity"]
|
||||
];
|
||||
}
|
||||
foreach ($trackinfo["Package"]["Activity"] as $history) {
|
||||
$location = new Location();
|
||||
$location->city = $history["ActivityLocation"]["Address"]["City"] ?? "";
|
||||
|
Loading…
x
Reference in New Issue
Block a user