From 0bf6e7466706ed2bce231aeba9803c31bdab931d Mon Sep 17 00:00:00 2001 From: antu chaudhary Date: Fri, 5 Jan 2024 13:15:47 +0530 Subject: [PATCH] some changes in upsshipping v2.0 --- src/Carriers/Ups.php | 6 ++---- src/Helpers/ShippingMethodHelper.php | 12 ++++++------ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/Carriers/Ups.php b/src/Carriers/Ups.php index 1ecbce5..a9176a8 100644 --- a/src/Carriers/Ups.php +++ b/src/Carriers/Ups.php @@ -13,7 +13,7 @@ class Ups extends AbstractShipping * Payment method code * * @var string - */ + */ protected $code = 'ups'; /** @@ -37,9 +37,7 @@ public function calculate() $marketplaceShipping = session()->get('marketplace_shipping_rates'); - if (isset($cartProducts) - && $cartProducts == true) { - + if (isset($cartProducts)) { foreach ($cartProducts as $key => $fedexServices) { $rate = $totalShippingCost = 0; $upsMethod = $methodCode = $key; diff --git a/src/Helpers/ShippingMethodHelper.php b/src/Helpers/ShippingMethodHelper.php index 1de4449..391e61e 100644 --- a/src/Helpers/ShippingMethodHelper.php +++ b/src/Helpers/ShippingMethodHelper.php @@ -61,6 +61,10 @@ public function getAllCartProducts($address) */ protected function createSoapClient($address) { + if (! core()->getConfigData('sales.carriers.ups.ups_active')) { + return false; + } + $cart = Cart::getCart(); $defaultChannel = core()->getCurrentChannelCode(); @@ -71,11 +75,6 @@ protected function createSoapClient($address) $adminCompany = $adminData->hostname; - if (! core()->getConfigData('sales.carriers.ups.ups_active')) { - - return false; - } - $sellerAdminData = $this->upsRepository->getSellerAdminData($cart->items()->get(), 'ups_postcode'); $sellerAdminServices = $allServices = []; @@ -280,11 +279,11 @@ protected function getServiceName($serviceCode) ]; foreach ($mapServices as $key => $service) { - if ($key == $serviceCode) { return $service; } } + return $serviceCode; } @@ -312,6 +311,7 @@ public function getWeight($weight) } else { $convertedWeight = $weight/0.45359237; } + return $convertedWeight; }