From b2be5cf11312dd099d6593f38c620b7ecc10701a Mon Sep 17 00:00:00 2001 From: bogdan202 Date: Wed, 18 Dec 2024 15:13:09 +0100 Subject: [PATCH] refs #49267 the alias list for PrestaShop iso country codes --- services/TrackingParameters.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/services/TrackingParameters.php b/services/TrackingParameters.php index 3d20179c..16d79e02 100644 --- a/services/TrackingParameters.php +++ b/services/TrackingParameters.php @@ -30,6 +30,7 @@ use Configuration; use Country; use Exception; +use PaypalAddons\classes\Constants\CountryIsoAlias; use PaypalAddons\classes\Constants\TrackingParameters as Map; use PrestaShopLogger; use Throwable; @@ -64,19 +65,24 @@ public function getPaypalCarriersByCountry($isoCountry = null) $carriers = [ [ 'key' => Map::CARRIER_OTHER, - 'name' => Map::CARRIER_OTHER, + 'name' => Map::CARRIER_OTHER, ], ]; + $isoAliasList = CountryIsoAlias::getAliasList(); - if ($isoCountry === null) { - $isoCountry = $this->defaultCountry->iso_code; + if (empty($this->paypalCarriers[$isoCountry])) { + if (empty($isoAliasList[$isoCountry]) || empty($this->paypalCarriers[$isoAliasList[$isoCountry]])) { + return $carriers; + } + + $isoCountry = $isoAliasList[$isoCountry]; } if (empty($this->paypalCarriers[strtoupper($isoCountry)])) { return $carriers; } - return array_merge($carriers, $this->paypalCarriers[strtoupper($isoCountry)]); + return array_merge($carriers, $this->paypalCarriers[$isoCountry]); } public function getPaypalCarrierByPsCarrier($carrierRef)