From 27906d45c226e1f606c84edc7abc4d30a629a0ce Mon Sep 17 00:00:00 2001 From: BillyGriffiths <billy.griffiths@gmail.com> Date: Mon, 13 Feb 2023 16:04:36 +0200 Subject: [PATCH] Use sprintf() to build the tracking URL --- Model/Carrier/CustomShipping.php | 10 +++++----- Model/Carrier/uData.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Model/Carrier/CustomShipping.php b/Model/Carrier/CustomShipping.php index 5a8c8a4..af748b6 100644 --- a/Model/Carrier/CustomShipping.php +++ b/Model/Carrier/CustomShipping.php @@ -483,16 +483,16 @@ class CustomShipping extends AbstractCarrierOnline implements CarrierInterface if (!is_array($trackingValue)) { $trackingValue = [$trackingValue]; } - foreach ($trackingValue as $item) { + foreach ($trackingValue as $trackingReference) { $tracking = $this->_trackStatusFactory->create(); - $tracking->setCarrier(self::CODE); $tracking->setCarrierTitle($carrierTitle); - $tracking->setUrl(uData::TRACKING .$item); - $tracking->setTracking($item); - $tracking->addData($this->processTrackingDetails($item)); + $tracking->setUrl(sprintf(uData::TRACKING, $this->getBaseUrl(), $trackingReference)); + $tracking->setTracking($trackingReference); + $tracking->addData($this->processTrackingDetails($trackingReference)); $result->append($tracking); $counter ++; + echo (sprintf(uData::TRACKING, $this->getBaseUrl(), $trackingReference)); } //Tracking Details Not Available diff --git a/Model/Carrier/uData.php b/Model/Carrier/uData.php index 46e2652..8ea4070 100644 --- a/Model/Carrier/uData.php +++ b/Model/Carrier/uData.php @@ -10,7 +10,7 @@ namespace bobgo\CustomShipping\Model\Carrier; class uData { /** Tracking Endpoint */ - public const TRACKING = 'https://api.dev.ship.uafrica.com/tracking?channel=localhost&tracking_reference='; + public const TRACKING = 'https://api.dev.ship.uafrica.com/tracking?channel=%s&tracking_reference=%s'; /*** RATES API Endpoint*/ public const RATES_ENDPOINT = 'https://api.dev.ship.uafrica.com/rates-at-checkout/magento'; } -- GitLab