From 59e991ca68b1ef84b353697017b706c2cc611db0 Mon Sep 17 00:00:00 2001 From: O K Date: Sat, 27 Dec 2025 13:37:29 +0200 Subject: [PATCH] remove mapServiceCodeToApiClass override --- usps_api_bridge.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/usps_api_bridge.php b/usps_api_bridge.php index dbede74..ba65178 100644 --- a/usps_api_bridge.php +++ b/usps_api_bridge.php @@ -153,7 +153,7 @@ class Usps_Api_Bridge extends Module return $helper->generateForm([$fields_form]); } - public function calculateRate($params, $shipping_cost, $products, $originalModule) + public function calculateRate($params, $shipping_cost, $products, $originalModule) { require_once(dirname(__FILE__) . '/classes/UspsV3Client.php'); @@ -161,11 +161,11 @@ class Usps_Api_Bridge extends Module $token = $this->getAccessToken(); if (!$token) return false; - + // 2. Identify Service (Use the Module's ID, not the Cart's ID) // $originalModule->id_carrier is the carrier currently being calculated in the loop. $carrierId = (int)$originalModule->id_carrier; - + // Fallback for edge cases where module ID might be missing (rare) if (!$carrierId && isset($params->id_carrier)) { $carrierId = (int)$params->id_carrier; @@ -191,7 +191,7 @@ class Usps_Api_Bridge extends Module $sql = 'SELECT rate FROM `' . _DB_PREFIX_ . 'uspsl_cache_rate` WHERE id_cache = ' . (int)$zhCache->id . ' AND id_carrier = ' . (int)$carrierId; // Use the correct ID here too! - + $cachedRate = Db::getInstance()->getValue($sql); if ($cachedRate !== false && $cachedRate !== null) { @@ -226,16 +226,16 @@ class Usps_Api_Bridge extends Module // 9. Loop through boxes foreach ($packedBoxes as $packedBox) { - + $weightInLbs = $this->convertUnit($packedBox->getWeight(), 'g', 'lbs', 3); if ($weightInLbs < 0.1) $weightInLbs = 0.1; - $box = $packedBox->getBox(); + $box = $packedBox->getBox(); $length = $this->convertUnit($box->getOuterLength(), 'mm', 'in', 2); $width = $this->convertUnit($box->getOuterWidth(), 'mm', 'in', 2); $height = $this->convertUnit($box->getOuterDepth(), 'mm', 'in', 2); - $category = 'NONSTANDARD'; + $category = 'NONSTANDARD'; if ($newApiClass === 'USPS_GROUND_ADVANTAGE') { if ($length <= 22 && $width <= 18 && $height <= 15 && $weightInLbs >= 0.375 && $weightInLbs <= 25) { $category = 'MACHINABLE'; @@ -252,7 +252,7 @@ class Usps_Api_Bridge extends Module 'priceType' => $requestedPriceType, 'mailingDate' => date('Y-m-d', strtotime('+1 day')), 'processingCategory' => $category, - 'rateIndicator' => 'SP' + 'rateIndicator' => 'SP' ]; $flatRateIndicator = $this->mapBoxToRateIndicator($box->getReference()); @@ -286,7 +286,7 @@ class Usps_Api_Bridge extends Module $newCacheRate->id_cache = $zhCache->id; $newCacheRate->id_carrier = $carrierId; // Use Correct ID $newCacheRate->code = $methodCode; - $newCacheRate->rate = $totalPrice; + $newCacheRate->rate = $totalPrice; $newCacheRate->save(); } // ---------------------------------- @@ -403,7 +403,7 @@ class Usps_Api_Bridge extends Module */ private function mapServiceCodeToApiClass($oldCode, $isInternational) { - $this->externalLog(['mapServiceCodeToApiClass' => ['oldCode' => $oldCode, 'isInternational' => $isInternational]]); + // $this->externalLog(['mapServiceCodeToApiClass' => ['oldCode' => $oldCode, 'isInternational' => $isInternational]]); // 1. Define the Standard Map $map = [ // DOMESTIC @@ -429,7 +429,7 @@ class Usps_Api_Bridge extends Module // 2. International Override Logic // If the destination is International, but the mapped class is Domestic, swap it. - if ($isInternational) { + /* if ($isInternational) { switch ($apiClass) { case 'PRIORITY_MAIL': return 'PRIORITY_MAIL_INTERNATIONAL'; @@ -444,7 +444,7 @@ class Usps_Api_Bridge extends Module case 'LIBRARY_MAIL': return 'FIRST-CLASS_PACKAGE_INTERNATIONAL_SERVICE'; } - } + } */ return $apiClass; }