Add carrier tracking URL to tracking results
This commit is contained in:
parent
c2cc007106
commit
7ea940a977
@ -152,6 +152,14 @@ class Carriers {
|
||||
]
|
||||
];
|
||||
|
||||
const CARRIER_TRACKING_URLS = [
|
||||
"usps" => "https://tools.usps.com/go/TrackConfirmAction?qtc_tLabels1={{number}}",
|
||||
"ups" => "https://wwwapps.ups.com/WebTracking/processInputRequest?tracknum={{number}}",
|
||||
"fedex" => "https://www.fedex.com/fedextrack/?trknbr={{number}}",
|
||||
"dhl_express" => "https://mydhl.express.dhl/us/en/tracking.html#/results?id={{number}}",
|
||||
"helena_express" => "https://helena.express/track#{{number}}"
|
||||
];
|
||||
|
||||
public static function getCarrierName(string $carrier): string {
|
||||
// scan by internal ID
|
||||
foreach (Carriers::CARRIERS as $id => $info) {
|
||||
@ -184,4 +192,12 @@ class Carriers {
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
public static function getCarrierTrackingUrl($carrier, $code) {
|
||||
if (!empty(Carriers::CARRIER_TRACKING_URLS[$carrier])) {
|
||||
return str_replace("{{number}}", $code, Carriers::CARRIER_TRACKING_URLS[$carrier]);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -95,6 +95,7 @@ class TrackingInfo {
|
||||
"carrier" => [
|
||||
"code" => Carriers::getCarrierCode($this->getCarrier()),
|
||||
"name" => Carriers::getCarrierName($this->getCarrier()),
|
||||
"trackingurl" => Carriers::getCarrierTrackingUrl($this->getCarrier(), $this->getCode()),
|
||||
"attribution" => $this->attributionText,
|
||||
"logo" => $this->carrierImageUrl
|
||||
],
|
||||
|
Loading…
x
Reference in New Issue
Block a user