Fix UPS error when a tracking event doesn't have a date or time (wtf, UPS)

master
Skylar Ittner 2 years ago
parent ba8061f806
commit 1b9b0b3644

@ -135,7 +135,6 @@ class Tracking_UPS {
// $from->country = (string) $trackinfo->OriginCountryCode ?? "";
//
// $info->setFrom($from);
// Only one entry, so put it in itself so the loop works
if (!isset($trackinfo["Package"]["Activity"][0])) {
$trackinfo["Package"]["Activity"] = [
@ -148,10 +147,17 @@ class Tracking_UPS {
$location->state = $history["ActivityLocation"]["Address"]["StateProvinceCode"] ?? "";
$location->zip = $history["ActivityLocation"]["Address"]["PostalCode"] ?? "";
$location->country = $history["ActivityLocation"]["Address"]["CountryCode"] ?? "";
if (!empty($history["Date"]) && !empty($history["Time"])) {
$datetimestring = DateTime::createFromFormat('Ymd His', "$history[Date] $history[Time]")->format("c");
} else if (!empty($history["Date"])) {
$datetimestring = DateTime::createFromFormat('Ymd His', "$history[Date]")->format("c");
} else {
$datetimestring = "";
}
$info->appendHistoryEntry(new TrackingEntry(
TrackingStatus::UPSEventTypeToStatus($history["Status"]["Type"]),
$history["Status"]["Description"] ?? "Unknown",
DateTime::createFromFormat('Ymd His', "$history[Date] $history[Time]")->format("c"),
$datetimestring,
$location
));
}

Loading…
Cancel
Save