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

Loading…
Cancel
Save