diff --git a/CHANGELOG for v1.3.x.md b/CHANGELOG for v1.3.x.md deleted file mode 100644 index a10e212..0000000 --- a/CHANGELOG for v1.3.x.md +++ /dev/null @@ -1,7 +0,0 @@ -# CHANGELOG for v1.3.x - -#### This changelog consists the bug & security fixes and new features being included in the releases listed below. - -## **v1.3.3(10th of Jan, 2022)** - *Release* - -* [compatible] Compatible for v1.3.3 \ No newline at end of file diff --git a/CHANGELOG for v2.0.0.md b/CHANGELOG for v2.0.0.md new file mode 100644 index 0000000..c59799a --- /dev/null +++ b/CHANGELOG for v2.0.0.md @@ -0,0 +1,15 @@ +# CHANGELOG for v2.0.0 + +#### This changelog consists the bug & security fixes and new features being included in the releases listed below. + +## **v2.0.0** - *Development* + +* [feature] The admin can enable or disable the usps Shipping method. + +* [feature] The admin can set the ups shipping method name that will be shown from the front side. + +* [feature] The admin can define the allowed methods and weight units. + +* [feature] The admin can set packaging type and drop off type. + +* [feature] Dynamic shipping method for freight calculation. \ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 4a07d99..0000000 --- a/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2022 Bagisto - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/README.md b/README.md index 04d956b..4c3156e 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,57 @@ -# Introduction +### 1. Introduction: -Bagisto UPS Shipping add-on provides UPS Shipping methods for shipping the product. By using this, you can provide UPS (United Parcel Service) shipping. +UPS Shipping module provides UPS Shipping methods for shipping the product. By using this, you can provide UPS (United Parcel Service) shipping. UPS is widely acknowledged as a world-class company and now it is with the Bagisto. +This module works with the Bagisto core Package. To use this module you must have installed Bagisto. It packs in lots of demanding features that allows your business to scale in no time: -- The admin can enable or disable the UPS Shipping method. +* The admin can enable or disable the UPS Shipping method. -- The admin can set the UPS shipping method name that will be shown from the front side. +* The admin can set the UPS shipping method name that will be shown from the front side. -- The admin can define the allowed methods and weight units. +* The admin can define the allowed methods and weight units. -- Dynamic shipping method for freight calculation. +* Dynamic shipping method for freight calculation. -- Tax rate can be calculated based on UPS shipping +### 2. Requirements: -## Requirements: +* **Bagisto**: v2.0.0 -- **Bagisto**: v1.3.3 +### 3. Installation: -## Installation : -- Run the following command -``` +* Run the following command +~~~ composer require bagisto/bagisto-ups-shipping -``` +~~~ -- Run these commands below to complete the setup -``` +* Unzip the respective extension zip and then merge "packages" folders into project root directory. +* Change the module name according to the providers like- (bagisto-ups-shipping) to (UpsShipping) +* Goto config/app.php file and add following line under 'providers' + +~~~ +Webkul\UpsShipping\Providers\UpsShippingServiceProvider::class +~~~ + +* Goto composer.json file and add following line under 'psr-4' + +~~~ +"Webkul\\UpsShipping\\": "packages/Webkul/UpsShipping/src" +~~~ + +* Run these commands below to complete the setup + +~~~ composer dump-autoload -``` +~~~ + +~~~ +php artisan optimize:clear +~~~ -``` -php artisan route:cache -php artisan optimize +~~~ php artisan vendor:publish -``` + -> Press 0 and then press enter to publish all assets and configurations. +~~~ -> now execute the project on your specified domain. +> now execute the project on your specified domain. \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/.gitignore b/packages/Webkul/UpsShipping/.gitignore new file mode 100644 index 0000000..2dc6ccf --- /dev/null +++ b/packages/Webkul/UpsShipping/.gitignore @@ -0,0 +1,3 @@ +/node_modules +/npm-debug.log +/package-lock.json \ No newline at end of file diff --git a/composer.json b/packages/Webkul/UpsShipping/composer.json similarity index 58% rename from composer.json rename to packages/Webkul/UpsShipping/composer.json index 9f7d67d..57d68be 100644 --- a/composer.json +++ b/packages/Webkul/UpsShipping/composer.json @@ -1,18 +1,13 @@ { - "name": "bagisto/bagisto-ups-shipping", + "name": "bagisto/laravel-ups", "license": "MIT", "authors": [ { - "name": "Naresh Verma", - "email": "naresh.verma327@webkul.com" - }, { - "name": "Vivek Sharma", - "email": "viveksh047@webkul.com" + "name": "Bagisto", + "email": "support@bagisto.com" } ], - "require": { - "konekt/concord": "^1.2" - }, + "require": {}, "autoload": { "psr-4": { "Webkul\\UpsShipping\\": "src/" diff --git a/packages/Webkul/UpsShipping/package.json b/packages/Webkul/UpsShipping/package.json new file mode 100644 index 0000000..e69795f --- /dev/null +++ b/packages/Webkul/UpsShipping/package.json @@ -0,0 +1,13 @@ +{ + "private": true, + "scripts": { + "dev": "vite", + "build": "vite build" + }, + "devDependencies": { + "axios": "^1.4.0", + "laravel-vite-plugin": "^0.7.2", + "postcss": "^8.4.23", + "vite": "^4.0.0" + } +} \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/postcss.config.js b/packages/Webkul/UpsShipping/postcss.config.js new file mode 100644 index 0000000..63889e7 --- /dev/null +++ b/packages/Webkul/UpsShipping/postcss.config.js @@ -0,0 +1,6 @@ +module.exports = { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +}; \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/src/Carriers/Ups.php b/packages/Webkul/UpsShipping/src/Carriers/Ups.php new file mode 100644 index 0000000..279bda4 --- /dev/null +++ b/packages/Webkul/UpsShipping/src/Carriers/Ups.php @@ -0,0 +1,89 @@ +isAvailable()) { + return false; + } + + $shippingRates = []; + + $cart = Cart::getCart(); + + $address = $cart->shipping_address; + + $shippingMethodHelper = app(ShippingMethodHelper::class); + + $cartProductsShippingData = $shippingMethodHelper->getAllCartProducts($address); + + if (! $cartProductsShippingData) { + return false; + } + + foreach ($cartProductsShippingData as $sellerId => $shippingMethods) { + $totalShippingCost = 0; + + $sellerRates = []; + + foreach ($shippingMethods as $methodCode => $methodData) { + $itemShippingCost = $methodData['rate'] * $methodData['itemQuantity']; + $marketplaceSellerId = $methodData['marketplace_seller_id']; + + $sellerRates[$marketplaceSellerId] = [ + 'amount' => core()->convertPrice($itemShippingCost), + 'base_amount' => $itemShippingCost, + ]; + + $totalShippingCost += $itemShippingCost; + } + + $cartShippingRate = new CartShippingRate; + + $cartShippingRate->carrier = 'mpups'; + + $cartShippingRate->carrier_title = $this->getConfigData('title'); + + $cartShippingRate->method = 'mpups_' . $sellerId; + + $cartShippingRate->method_title = $this->getConfigData('title'); + + $cartShippingRate->method_description = $sellerId; + + $cartShippingRate->price = core()->convertPrice($totalShippingCost); + + $cartShippingRate->base_price = $totalShippingCost; + + $shippingRates[] = $cartShippingRate; + + // Store rates in session + $marketplaceShippingRates = session()->get('marketplace_shipping_rates', []); + + $marketplaceShippingRates['mpupsshipping'][$sellerId] = $sellerRates; + + session()->put('marketplace_shipping_rates', $marketplaceShippingRates); + } + + return $shippingRates; + } +} \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/src/Config/carriers.php b/packages/Webkul/UpsShipping/src/Config/carriers.php new file mode 100755 index 0000000..2244459 --- /dev/null +++ b/packages/Webkul/UpsShipping/src/Config/carriers.php @@ -0,0 +1,11 @@ + [ + 'code' => 'ups', + 'title' => 'UPS Shipping', + 'description' => 'UPS Shipping', + 'active' => true, + 'class' => 'Webkul\UpsShipping\Carriers\Ups', + ], +]; \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/src/Config/system.php b/packages/Webkul/UpsShipping/src/Config/system.php new file mode 100644 index 0000000..efc3e30 --- /dev/null +++ b/packages/Webkul/UpsShipping/src/Config/system.php @@ -0,0 +1,154 @@ + 'sales.carriers.ups', + 'name' => 'ups::app.admin.system.ups', + 'info' => 'ups::app.admin.system.ups-description', + 'sort' => 4, + 'fields' => [ + [ + 'name' => 'title', + 'title' => 'ups::app.admin.system.title', + 'type' => 'text', + 'validation' => 'required', + 'channel_based' => false, + 'locale_based' => true, + ], [ + 'name' => 'description', + 'title' => 'ups::app.admin.system.description', + 'type' => 'textarea', + 'channel_based' => false, + 'locale_based' => true, + ], [ + 'name' => 'ups_active', + 'title' => 'ups::app.admin.system.status', + 'type' => 'boolean', + ], [ + 'name' => 'mode', + 'title' => 'ups::app.admin.system.mode', + 'type' => 'select', + 'validation' => 'required', + 'options' => [ + [ + 'title' => 'Development', + 'value' => 'DEVELOPMENT', + ], [ + 'title' => 'Live', + 'value' => "LIVE", + ], + ], + ], [ + 'name' => 'access_license_key', + 'title' => 'ups::app.admin.system.access-license-number', + 'type' => 'text', + 'validation' => 'required', + 'channel_based' => false, + 'locale_based' => true, + ], [ + 'name' => 'user_id', + 'title' => 'ups::app.admin.system.user-id', + 'type' => 'text', + 'validation' => 'required', + 'channel_based' => false, + 'locale_based' => true, + ], [ + 'name' => 'password', + 'title' => 'ups::app.admin.system.password', + 'type' => 'password', + 'validation' => 'required', + 'channel_based' => false, + 'locale_based' => true, + ], [ + 'name' => 'shipper_number', + 'title' => 'ups::app.admin.system.shipper', + 'type' => 'text', + 'channel_based' => false, + 'locale_based' => true, + ], [ + 'name' => 'container', + 'title' => 'ups::app.admin.system.container', + 'type' => 'select', + 'validation' => 'required', + 'channel_based' => false, + 'locale_based' => true, + 'options' => [ + [ + 'title' => 'Package', + 'value' => '02', + ], [ + 'title' => 'UPS Letter', + 'value' => '01', + ], [ + 'title' => 'UPS Tube', + 'value' => '03', + ], [ + 'title' => 'UPS Pak', + 'value' => '04', + ], [ + 'title' => 'UPS Express Box', + 'value' => '21', + ], + ], + ], [ + 'name' => 'weight_unit', + 'title' => 'ups::app.admin.system.weight-unit', + 'type' => 'select', + 'validation' => 'required', + 'channel_based' => false, + 'locale_based' => true, + 'options' => [ + [ + 'title' => 'LBS', + 'value' => 'LBS', + ], [ + 'title' => 'KGS', + 'value' => 'KGS', + ], + ], + ], [ + 'name' => 'services', + 'title' => 'ups::app.admin.system.allowed-methods', + 'type' => 'multiselect', + 'channel_based' => true, + 'locale_based' => true, + 'options' => [ + [ + 'title' => 'Next Day Air Early AM', + 'value' => '14', + ], [ + 'title' => 'Next Day Air', + 'value' => '01', + ], [ + 'title' => 'Next Day Air Saver', + 'value' => '13', + ], [ + 'title' => '2nd Day Air AM', + 'value' => '59', + ], [ + 'title' => '2nd Day Air', + 'value' => '02', + ], [ + 'title' => '3 Day Select', + 'value' => '12', + ], [ + 'title' => 'Ups Ground', + 'value' => '03', + ], [ + 'title' => 'UPS Worldwide Express', + 'value' => '07', + ], [ + 'title' => 'UPS Worldwide Express Plus', + 'value' => '54', + ], [ + 'title' => 'UPS Worldwide Expedited', + 'value' => '08', + ], [ + 'title' => 'UPS World Wide Saver', + 'value' => '65', + ], + ], + ], + ], + ], +]; \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/src/Helpers/ShippingMethodHelper.php b/packages/Webkul/UpsShipping/src/Helpers/ShippingMethodHelper.php new file mode 100644 index 0000000..d4bfe39 --- /dev/null +++ b/packages/Webkul/UpsShipping/src/Helpers/ShippingMethodHelper.php @@ -0,0 +1,329 @@ +getShippingRates($address); + } + + /** + * Retrieve shipping rates via SOAP client. + * + * @param object $address + * @return array|false + */ + protected function getShippingRates($address) + { + if (! core()->getConfigData('sales.carriers.ups.ups_active')) { + return false; + } + + $cart = Cart::getCart(); + + $defaultChannel = core()->getCurrentChannelCode(); + + $adminData = $this->channel->findByField('code', $defaultChannel)->first(); + + $adminName = $adminData->name; + + $adminCompany = $adminData->hostname; + + $sellerAdminData = $this->upsRepository->getSellerAdminData($cart->items()->get(), 'ups_postcode'); + + $sellerAdminServices = $allServices = []; + + foreach ($sellerAdminData as $cartProduct) { + $sellerAdminServices[0] = explode(",", core()->getConfigData('sales.carriers.ups.services')); + } + + foreach ($sellerAdminData as $cartProduct) { + $weight = $this->convertWeightToLbs($cartProduct->weight); + $countryId = core()->getConfigData('sales.shipping.origin.country'); + + if (! empty($cartProduct->marketplace_seller_id)) { + $zoneInformation = core()->getConfigData('sales.shipping.origin.state'); + $address1 = core()->getConfigData('sales.shipping.origin.address1'); + $city = core()->getConfigData('sales.shipping.origin.city'); + } + + $accessKey = core()->getConfigData('sales.carriers.ups.access_license_key'); + $userId = core()->getConfigData('sales.carriers.ups.user_id'); + $password = core()->getConfigData('sales.carriers.ups.password'); + $shipperNumber = core()->getConfigData('sales.carriers.ups.shipper_number'); + + $shipperNumber = $shipperNumber ?? ''; + + // Build XML request for SOAP + $accessRequestXML = new \SimpleXMLElement(""); + $rateRequestXML = new \SimpleXMLElement(""); + + // Build AccessRequest XML + $accessRequestXML->addChild("AccessLicenseNumber", $accessKey); + $accessRequestXML->addChild("UserId", $userId); + $accessRequestXML->addChild("Password", $password); + + // Build RateRequest XML + $request = $rateRequestXML->addChild('Request'); + $request->addChild("RequestAction", "Rate"); + $request->addChild("RequestOption", "Shop"); + + // Build Shipper section + $shipment = $rateRequestXML->addChild('Shipment'); + $shipper = $shipment->addChild('Shipper'); + + // Shipper details + if (!empty($cartProduct->marketplace_seller_id)) { + $shipper->addChild("Name", $adminName); + $shipper->addChild("ShipperNumber", $shipperNumber); + + $shipperAddress = $shipper->addChild('Address'); + $shipperAddress->addChild("AddressLine1", $address1 ? $address1 : ''); + $shipperAddress->addChild("City", $city ? $city : ''); + $shipperAddress->addChild("PostalCode", core()->getConfigData('sales.shipping.origin.zipcode')); + $shipperAddress->addChild("CountryCode", $countryId); + + $shipFrom = $shipment->addChild('ShipFrom'); + $shipFrom->addChild("CompanyName", $adminCompany); + + $shipFromAddress = $shipFrom->addChild('Address'); + $shipFromAddress->addChild("AddressLine1", $address1 ? $address1 : ''); + $shipFromAddress->addChild("City", $city ? $city : ''); + $shipFromAddress->addChild("StateProvinceCode", $zoneInformation); + $shipFromAddress->addChild("PostalCode", core()->getConfigData('sales.shipping.origin.zipcode')); + $shipFromAddress->addChild("CountryCode", $countryId); + } + + // ShipTo details + $shipTo = $shipment->addChild('ShipTo'); + $shipTo->addChild("CompanyName", $address->first_name . ' ' . $address->last_name); + + $shipToAddress = $shipTo->addChild('Address'); + $shipToAddress->addChild("AddressLine1", $address->address1); + $shipToAddress->addChild("City", $address->city); + + if ($address->country == 'PR') { + $shipToAddress->addChild("PostalCode", '00' . $address->postcode); + } else { + $shipToAddress->addChild("PostalCode", $address->postcode); + } + + $shipToAddress->addChild("CountryCode", $address->country); + + // Package details + $package = $shipment->addChild('Package'); + $packageType = $package->addChild('PackagingType'); + $packageType->addChild("Code", core()->getConfigData('sales.carriers.ups.container')); + + $packageWeight = $package->addChild('PackageWeight'); + $unitOfMeasurement = $packageWeight->addChild('UnitOfMeasurement'); + $unitOfMeasurement->addChild("Code", "LBS"); + $packageWeight->addChild("Weight", $weight); + + $requestXML = $accessRequestXML->asXML() . $rateRequestXML->asXML(); + + try { + $url = 'https://onlinetools.ups.com/ups.app/xml/Rate'; + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); + curl_setopt($ch, CURLOPT_TIMEOUT, 30); + curl_setopt($ch, CURLOPT_POST, true); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_HTTPHEADER, array( + "Content-type: text/xml", + "Accept: text/xml", + "Cache-Control: no-cache", + "Pragma: no-cache", + )); + curl_setopt($ch, CURLOPT_POSTFIELDS, $requestXML); + + $response = curl_exec($ch); + + curl_close($ch); + + $upsServiceArray = simplexml_load_string($response); + + $upsServices = json_decode(json_encode($upsServiceArray)); + + $sellerId = 0; + if (! empty($cartProduct->marketplace_seller_id)) { + $sellerId = $cartProduct->marketplace_seller_id; + } + + if ($response + && isset($upsServices->Response->ResponseStatusDescription) + && $upsServices->Response->ResponseStatusDescription == 'Success' + ) { + + if (isset($upsServices->RatedShipment)) { + foreach ($upsServices->RatedShipment as $service) { + $serviceCode = $service->Service->Code; + $matchResult = $this->upsRepository->validateAllowedMethods($serviceCode, $sellerAdminServices); + $serviceName = $this->getServiceName($serviceCode); + + if ($matchResult) { + $cartProductServices[$serviceName] = [ + 'classId' => $serviceCode, + 'rate' => $service->RatedPackage->TotalCharges->MonetaryValue, + 'currency' => $service->RatedPackage->TotalCharges->CurrencyCode, + 'weight' => $service->BillingWeight->Weight, + 'weightUnit' => $service->BillingWeight->UnitOfMeasurement->Code, + 'marketplace_seller_id' => $sellerId, + 'itemQuantity' => $cartProduct->quantity, + ]; + } + } + + if (! empty($cartProductServices)) { + $allServices[] = $cartProductServices; + } + } + } else { + $errorLog = $this->getErrorLog($upsServices); + + return false; + //to check the error generated in the method; + } + } catch (\Exception $e) { + return false; + } + } + + if (! empty($allServices)) { + return $this->upsRepository->getCommonMethods($allServices); + } else { + return false; + } + } + + /** + * Convert weight to LBS if necessary. + * + * @param string $weight + * @return float + */ + public function convertWeightToLbs($weight) + { + $coreWeightUnit = strtoupper(core()->getConfigData('general.general.locale_options.weight_unit')); + + $upsWeightUnit = strtoupper(core()->getConfigData('sales.carriers.ups.weight_unit')); + + $convertedWeight = ''; + + if ($coreWeightUnit == 'LBS') { + if ($upsWeightUnit == 'LBS') { + $convertedWeight = $weight; + } else { + // Convert kgs to lbs + $convertedWeight = $weight / 0.45359237; + } + } else { + $convertedWeight = $weight / 0.45359237; + } + + return $convertedWeight; + } + + /** + * Log the error. + * + * @param object $errors + * @return bool + */ + public function getErrorLog($errors) + { + $exception = []; + + if (is_array($errors->Response->Error)) { + foreach ($errors->Response->Error as $errorLog) { + $exception[] = $errorLog->ErrorDescription; + } + } else { + $exception[] = $errors->Response->Error->ErrorDescription; + } + + $status = is_array($errors->Response->Error) ? $errors->Response->ResponseStatusDescription : $errors->Response->Error->ErrorSeverity; + + $logs = [ + 'status' => $status, + 'description' => $exception, + ]; + + $shippingLog = new Logger('shipping'); + $shippingLog->pushHandler(new StreamHandler(storage_path('logs/ups.log')), Logger::INFO); + $shippingLog->info('shipping', $logs); + + return true; + } + + /** + * Map service code to service name. + * + * @param string $serviceCode + * @return string + */ + protected function getServiceName($serviceCode) + { + $mapServices = [ + '01' => 'Next Day Air', + '02' => '2nd Day Air', + '03' => 'Ups Ground', + '07' => 'Ups Worldwide Express', + '08' => 'Ups Worldwide Expedited', + '11' => 'Standard', + '12' => '3 Day Select', + '13' => 'Next Day Air Saver', + '14' => 'Next Day Air Early A.M.', + '54' => 'Ups Worldwide Express Plus', + '59' => '2nd Day Air A.M.', + '65' => 'UPS World Wide Saver', + '82' => 'Today Standard', + '83' => 'Today Dedicated Courier', + '84' => 'Today Intercity', + '85' => 'Today Express', + '86' => 'Today Express Saver', + '03' => 'Ups Ground', + ]; + + foreach ($mapServices as $key => $service) { + if ($key == $serviceCode) { + return $service; + } + } + + return $serviceCode; + } +} \ No newline at end of file diff --git a/src/Providers/UpsShippingServiceProvider.php b/packages/Webkul/UpsShipping/src/Providers/UpsShippingServiceProvider.php old mode 100644 new mode 100755 similarity index 69% rename from src/Providers/UpsShippingServiceProvider.php rename to packages/Webkul/UpsShipping/src/Providers/UpsShippingServiceProvider.php index 764836e..3ecfdb3 --- a/src/Providers/UpsShippingServiceProvider.php +++ b/packages/Webkul/UpsShipping/src/Providers/UpsShippingServiceProvider.php @@ -14,7 +14,16 @@ class UpsShippingServiceProvider extends ServiceProvider */ public function boot(Router $router) { + $this->loadMigrationsFrom(__DIR__ . '/../Database/Migrations'); + $this->loadTranslationsFrom(__DIR__ . '/../Resources/lang', 'ups'); + + $this->loadViewsFrom(__DIR__ . '/../Resources/views', 'ups'); + + $this->publishes([ + __DIR__ . '/../Resources/views/configurations/field-type.blade.php' => + __DIR__ . '/../../../Admin/src/Resources/views/configuration/field-type.blade.php', + ]); } /** diff --git a/packages/Webkul/UpsShipping/src/Repositories/UpsRepository.php b/packages/Webkul/UpsShipping/src/Repositories/UpsRepository.php new file mode 100644 index 0000000..73b6cf7 --- /dev/null +++ b/packages/Webkul/UpsShipping/src/Repositories/UpsRepository.php @@ -0,0 +1,93 @@ +getConfigData('sales.carriers.ups.ups_services')); + + $allowedMethods = []; + + foreach ($allServices as $services) { + $allowedMethod = array_filter($services, function ($serviceCode) use ($allowedServiceCodes) { + return in_array($serviceCode, $allowedServiceCodes); + }, ARRAY_FILTER_USE_KEY); + + if (! empty($allowedMethod)) { + $allowedMethods[] = $allowedMethod; + } + } + + return (! empty($allowedMethods)) ? $this->getCommonMethods($allowedMethods) : false; + } + + /** + * Get the common methods among provided methods + * + * @param array $methods + * @return array|false + */ + public function getCommonMethods($methods) + { + $availableServiceCodes = []; + + foreach ($methods as $upsMethods) { + $availableServiceCodes = array_merge($availableServiceCodes, array_keys($upsMethods)); + } + + $methodsCount = count($methods); + + $serviceCounts = array_count_values($availableServiceCodes); + + $finalServices = []; + + foreach ($serviceCounts as $serviceCode => $serviceCount) { + if ($serviceCount == $methodsCount) { + foreach ($methods as $upsMethods) { + if (isset($upsMethods[$serviceCode])) { + $finalServices[$serviceCode][] = $upsMethods[$serviceCode]; + } + } + } + } + + return (! empty($finalServices)) ? $finalServices : false; + } +} \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/src/Resources/assets/css/app.css b/packages/Webkul/UpsShipping/src/Resources/assets/css/app.css new file mode 100644 index 0000000..bd6213e --- /dev/null +++ b/packages/Webkul/UpsShipping/src/Resources/assets/css/app.css @@ -0,0 +1,3 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/src/Resources/assets/js/app.js b/packages/Webkul/UpsShipping/src/Resources/assets/js/app.js new file mode 100644 index 0000000..82fc4ad --- /dev/null +++ b/packages/Webkul/UpsShipping/src/Resources/assets/js/app.js @@ -0,0 +1,4 @@ +/** + * This will track all the images and fonts for publishing. + */ +import.meta.glob(["../images/**", "../fonts/**"]); \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/src/Resources/lang/ar/app.php b/packages/Webkul/UpsShipping/src/Resources/lang/ar/app.php new file mode 100755 index 0000000..b83b9f0 --- /dev/null +++ b/packages/Webkul/UpsShipping/src/Resources/lang/ar/app.php @@ -0,0 +1,23 @@ + [ + 'system' => [ + 'title' => 'العنوان', + 'description' => 'الوصف', + 'status' => 'الحالة', + 'ups' => 'شحن UPS', + 'ups-description' => 'الشحن عبر الإنترنت مع UPS، قم بإرسال وتوصيل الطرود بشكل أسرع وأسهل من أي وقت مضى.', + 'gateway-url' => 'رابط البوابة', + 'user-id' => 'معرف المستخدم', + 'access-license-number' => 'مفتاح رخصة الوصول', + 'shipper' => 'رقم الشحن', + 'weight-unit' => 'وحدة الوزن', + 'password' => 'كلمة المرور', + 'mode' => 'الوضع', + 'container' => 'الحاوية', + 'size' => 'الحجم', + 'allowed-methods' => 'الخدمات المسموح بها', + ], + ], +]; \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/src/Resources/lang/bn/app.php b/packages/Webkul/UpsShipping/src/Resources/lang/bn/app.php new file mode 100644 index 0000000..d7e81c4 --- /dev/null +++ b/packages/Webkul/UpsShipping/src/Resources/lang/bn/app.php @@ -0,0 +1,23 @@ + [ + 'system' => [ + 'title' => 'শিরোনাম', + 'description' => 'বর্ণনা', + 'status' => 'অবস্থা', + 'ups' => 'ইউপিএস শিপিং', + 'ups-description' => 'ইউপিএস দ্বারা অনলাইন শিপিং, পার্সেল পাঠানো এবং ডেলিভারি করা হোক সহজ এবং দ্রুততর হবে সহজে।', + 'gateway-url' => 'গেটওয়ে ইউআরএল', + 'user-id' => 'ব্যবহারকারী আইডি', + 'access-license-number' => 'অ্যাক্সেস লাইসেন্স কী', + 'shipper' => 'শিপার নম্বর', + 'weight-unit' => 'ওজন ইউনিট', + 'password' => 'পাসওয়ার্ড', + 'mode' => 'মোড', + 'container' => 'কনটেইনার', + 'size' => 'আকার', + 'allowed-methods' => 'অনুমোদিত সেবাসমূহ', + ], + ], +]; \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/src/Resources/lang/de/app.php b/packages/Webkul/UpsShipping/src/Resources/lang/de/app.php new file mode 100755 index 0000000..aab7b71 --- /dev/null +++ b/packages/Webkul/UpsShipping/src/Resources/lang/de/app.php @@ -0,0 +1,23 @@ + [ + 'system' => [ + 'title' => 'Titel', + 'description' => 'Beschreibung', + 'status' => 'Status', + 'ups' => 'UPS Versand', + 'ups-description' => 'Online-Versand mit UPS, Senden und Liefern von Paketen schneller und einfacher als je zuvor.', + 'gateway-url' => 'Gateway URL', + 'user-id' => 'Benutzer-ID', + 'access-license-number' => 'Zugriffslizenzschlüssel', + 'shipper' => 'Versender-Nummer', + 'weight-unit' => 'Gewichtseinheit', + 'password' => 'Passwort', + 'mode' => 'Modus', + 'container' => 'Behälter', + 'size' => 'Größe', + 'allowed-methods' => 'Erlaubte Dienste', + ], + ], +]; \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/src/Resources/lang/en/app.php b/packages/Webkul/UpsShipping/src/Resources/lang/en/app.php new file mode 100644 index 0000000..f46b45f --- /dev/null +++ b/packages/Webkul/UpsShipping/src/Resources/lang/en/app.php @@ -0,0 +1,23 @@ + [ + 'system' => [ + 'title' => 'Title', + 'description' => 'Description', + 'status' => 'Status', + 'ups' => 'UPS Shipping', + 'ups-description' => 'Online shipping with UPS, Send and deliver packages faster easier than ever.', + 'gateway-url' => 'Gateway URL', + 'user-id' => 'User ID' , + 'access-license-number' => 'Access License Key', + 'shipper' => 'Shipper Number', + 'weight-unit' => 'Weight Unit', + 'password' => 'Password', + 'mode' => 'Mode', + 'container' => 'Container', + 'size' => 'Size', + 'allowed-methods' => 'Allowed Services', + ], + ], +]; \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/src/Resources/lang/es/app.php b/packages/Webkul/UpsShipping/src/Resources/lang/es/app.php new file mode 100755 index 0000000..180a3c1 --- /dev/null +++ b/packages/Webkul/UpsShipping/src/Resources/lang/es/app.php @@ -0,0 +1,23 @@ + [ + 'system' => [ + 'title' => 'Título', + 'description' => 'Descripción', + 'status' => 'Estado', + 'ups' => 'Envío UPS', + 'ups-description' => 'Envío en línea con UPS, Envía y entrega paquetes más rápido y más fácil que nunca.', + 'gateway-url' => 'URL del portal', + 'user-id' => 'ID de usuario', + 'access-license-number' => 'Clave de licencia de acceso', + 'shipper' => 'Número de remitente', + 'weight-unit' => 'Unidad de peso', + 'password' => 'Contraseña', + 'mode' => 'Modo', + 'container' => 'Contenedor', + 'size' => 'Tamaño', + 'allowed-methods' => 'Servicios permitidos', + ], + ], +]; \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/src/Resources/lang/fa/app.php b/packages/Webkul/UpsShipping/src/Resources/lang/fa/app.php new file mode 100755 index 0000000..edd0fbc --- /dev/null +++ b/packages/Webkul/UpsShipping/src/Resources/lang/fa/app.php @@ -0,0 +1,23 @@ + [ + 'system' => [ + 'title' => 'عنوان', + 'description' => 'توضیحات', + 'status' => 'وضعیت', + 'ups' => 'حمل و نقل UPS', + 'ups-description' => 'حمل و نقل آنلاین با UPS، ارسال و تحویل بسته‌ها سریع‌تر و آسان‌تر از همیشه.', + 'gateway-url' => 'آدرس دروازه', + 'user-id' => 'شناسه کاربر', + 'access-license-number' => 'کلید لایسنس دسترسی', + 'shipper' => 'شماره فرستنده', + 'weight-unit' => 'واحد وزن', + 'password' => 'گذرواژه', + 'mode' => 'حالت', + 'container' => 'ظرف', + 'size' => 'اندازه', + 'allowed-methods' => 'خدمات مجاز', + ], + ], +]; \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/src/Resources/lang/fr/app.php b/packages/Webkul/UpsShipping/src/Resources/lang/fr/app.php new file mode 100755 index 0000000..838aa85 --- /dev/null +++ b/packages/Webkul/UpsShipping/src/Resources/lang/fr/app.php @@ -0,0 +1,23 @@ + [ + 'system' => [ + 'title' => 'Titre', + 'description' => 'Description', + 'status' => 'Statut', + 'ups' => 'Expédition UPS', + 'ups-description' => 'Expédition en ligne avec UPS, Envoyez et livrez des colis plus rapidement et plus facilement que jamais.', + 'gateway-url' => 'URL de la passerelle', + 'user-id' => 'Identifiant utilisateur', + 'access-license-number' => 'Clé de licence d'accès', + 'shipper' => 'Numéro d'expéditeur', + 'weight-unit' => 'Unité de poids', + 'password' => 'Mot de passe', + 'mode' => 'Mode', + 'container' => 'Conteneur', + 'size' => 'Taille', + 'allowed-methods' => 'Services autorisés', + ], + ], +]; \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/src/Resources/lang/he/app.php b/packages/Webkul/UpsShipping/src/Resources/lang/he/app.php new file mode 100755 index 0000000..5093454 --- /dev/null +++ b/packages/Webkul/UpsShipping/src/Resources/lang/he/app.php @@ -0,0 +1,23 @@ + [ + 'system' => [ + 'title' => 'כותרת', + 'description' => 'תיאור', + 'status' => 'מצב', + 'ups' => 'משלוח UPS', + 'ups-description' => 'משלוח דיגיטלי עם UPS, שלח ומסיר חבילות מהיר יותר וקל יותר מתמיד.', + 'gateway-url' => 'כתובת URL של השער', + 'user-id' => 'מזהה משתמש', + 'access-license-number' => 'מפתח רישיון גישה', + 'shipper' => 'מספר שולח', + 'weight-unit' => 'יחידת משקל', + 'password' => 'סיסמה', + 'mode' => 'מצב', + 'container' => 'מיכל', + 'size' => 'גודל', + 'allowed-methods' => 'שירותים מורשים', + ], + ], +]; \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/src/Resources/lang/hi_IN/app.php b/packages/Webkul/UpsShipping/src/Resources/lang/hi_IN/app.php new file mode 100755 index 0000000..97018ed --- /dev/null +++ b/packages/Webkul/UpsShipping/src/Resources/lang/hi_IN/app.php @@ -0,0 +1,23 @@ + [ + 'system' => [ + 'title' => 'शीर्षक', + 'description' => 'विवरण', + 'status' => 'स्थिति', + 'ups' => 'UPS शिपिंग', + 'ups-description' => 'UPS के साथ ऑनलाइन शिपिंग, पैकेज को तेज़ी से भेजें और डिलीवर करें, कभी भी से भी आसान और तेज़ी से।', + 'gateway-url' => 'गेटवे URL', + 'user-id' => 'उपयोगकर्ता आईडी', + 'access-license-number' => 'पहुंच लाइसेंस कुंजी', + 'shipper' => 'शिपर नंबर', + 'weight-unit' => 'वजन इकाई', + 'password' => 'पासवर्ड', + 'mode' => 'मोड', + 'container' => 'कंटेनर', + 'size' => 'आकार', + 'allowed-methods' => 'अनुमत सेवाएं', + ], + ], +]; \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/src/Resources/lang/it/app.php b/packages/Webkul/UpsShipping/src/Resources/lang/it/app.php new file mode 100755 index 0000000..a7cd36c --- /dev/null +++ b/packages/Webkul/UpsShipping/src/Resources/lang/it/app.php @@ -0,0 +1,23 @@ + [ + 'system' => [ + 'title' => 'Titolo', + 'description' => 'Descrizione', + 'status' => 'Stato', + 'ups' => 'Spedizione UPS', + 'ups-description' => 'Spedizione online con UPS, Invia e consegna pacchi più velocemente e più facilmente che mai.', + 'gateway-url' => 'URL del gateway', + 'user-id' => 'ID utente', + 'access-license-number' => 'Chiave di licenza di accesso', + 'shipper' => 'Numero del mittente', + 'weight-unit' => 'Unità di peso', + 'password' => 'Password', + 'mode' => 'Modalità', + 'container' => 'Contenitore', + 'size' => 'Dimensione', + 'allowed-methods' => 'Servizi consentiti', + ], + ], +]; \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/src/Resources/lang/ja/app.php b/packages/Webkul/UpsShipping/src/Resources/lang/ja/app.php new file mode 100755 index 0000000..2860fcf --- /dev/null +++ b/packages/Webkul/UpsShipping/src/Resources/lang/ja/app.php @@ -0,0 +1,23 @@ + [ + 'system' => [ + 'title' => 'タイトル', + 'description' => '説明', + 'status' => 'ステータス', + 'ups' => 'UPS 配送', + 'ups-description' => 'UPS を使用したオンライン配送、より簡単で迅速なパッケージの送信と配達。', + 'gateway-url' => 'ゲートウェイ URL', + 'user-id' => 'ユーザー ID', + 'access-license-number' => 'アクセス ライセンス キー', + 'shipper' => '出荷者番号', + 'weight-unit' => '重量単位', + 'password' => 'パスワード', + 'mode' => 'モード', + 'container' => 'コンテナ', + 'size' => 'サイズ', + 'allowed-methods' => '許可されたサービス', + ], + ], +]; \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/src/Resources/lang/nl/app.php b/packages/Webkul/UpsShipping/src/Resources/lang/nl/app.php new file mode 100755 index 0000000..186813a --- /dev/null +++ b/packages/Webkul/UpsShipping/src/Resources/lang/nl/app.php @@ -0,0 +1,23 @@ + [ + 'system' => [ + 'title' => 'Titel', + 'description' => 'Omschrijving', + 'status' => 'Status', + 'ups' => 'UPS Verzending', + 'ups-description' => 'Online verzending met UPS, Stuur en bezorg pakketten sneller en gemakkelijker dan ooit.', + 'gateway-url' => 'Gateway URL', + 'user-id' => 'Gebruikers-ID', + 'access-license-number' => 'Toegang Licentiesleutel', + 'shipper' => 'Afzender Nummer', + 'weight-unit' => 'Gewichtseenheid', + 'password' => 'Wachtwoord', + 'mode' => 'Modus', + 'container' => 'Container', + 'size' => 'Grootte', + 'allowed-methods' => 'Toegestane Diensten', + ], + ], +]; \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/src/Resources/lang/pl/app.php b/packages/Webkul/UpsShipping/src/Resources/lang/pl/app.php new file mode 100755 index 0000000..30e8f9a --- /dev/null +++ b/packages/Webkul/UpsShipping/src/Resources/lang/pl/app.php @@ -0,0 +1,23 @@ + [ + 'system' => [ + 'title' => 'Tytuł', + 'description' => 'Opis', + 'status' => 'Status', + 'ups' => 'Wysyłka UPS', + 'ups-description' => 'Wysyłka online z UPS, Wysyłaj i dostarczaj paczki szybciej i łatwiej niż kiedykolwiek.', + 'gateway-url' => 'URL Bramy', + 'user-id' => 'ID Użytkownika', + 'access-license-number' => 'Klucz Licencji Dostępu', + 'shipper' => 'Numer Nadawcy', + 'weight-unit' => 'Jednostka Wagi', + 'password' => 'Hasło', + 'mode' => 'Tryb', + 'container' => 'Kontener', + 'size' => 'Rozmiar', + 'allowed-methods' => 'Dozwolone Usługi', + ], + ], +]; \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/src/Resources/lang/pt_BR/app.php b/packages/Webkul/UpsShipping/src/Resources/lang/pt_BR/app.php new file mode 100755 index 0000000..32918f8 --- /dev/null +++ b/packages/Webkul/UpsShipping/src/Resources/lang/pt_BR/app.php @@ -0,0 +1,23 @@ + [ + 'system' => [ + 'title' => 'Título', + 'description' => 'Descrição', + 'status' => 'Status', + 'ups' => 'Envio UPS', + 'ups-description' => 'Envio online com a UPS, Envie e entregue pacotes mais rápido e mais fácil do que nunca.', + 'gateway-url' => 'URL do Gateway', + 'user-id' => 'ID do Usuário', + 'access-license-number' => 'Chave de Licença de Acesso', + 'shipper' => 'Número do Remetente', + 'weight-unit' => 'Unidade de Peso', + 'password' => 'Senha', + 'mode' => 'Modo', + 'container' => 'Contêiner', + 'size' => 'Tamanho', + 'allowed-methods' => 'Serviços Permitidos', + ], + ], +]; \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/src/Resources/lang/ru/app.php b/packages/Webkul/UpsShipping/src/Resources/lang/ru/app.php new file mode 100755 index 0000000..caed43d --- /dev/null +++ b/packages/Webkul/UpsShipping/src/Resources/lang/ru/app.php @@ -0,0 +1,23 @@ + [ + 'system' => [ + 'title' => 'Заголовок', + 'description' => 'Описание', + 'status' => 'Статус', + 'ups' => 'Доставка UPS', + 'ups-description' => 'Онлайн-доставка с UPS, Отправляйте и доставляйте посылки быстрее и проще, чем когда-либо.', + 'gateway-url' => 'URL шлюза', + 'user-id' => 'Идентификатор пользователя', + 'access-license-number' => 'Ключ лицензии доступа', + 'shipper' => 'Номер отправителя', + 'weight-unit' => 'Единица веса', + 'password' => 'Пароль', + 'mode' => 'Режим', + 'container' => 'Контейнер', + 'size' => 'Размер', + 'allowed-methods' => 'Разрешенные услуги', + ], + ], +]; \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/src/Resources/lang/sin/app.php b/packages/Webkul/UpsShipping/src/Resources/lang/sin/app.php new file mode 100755 index 0000000..abd8b70 --- /dev/null +++ b/packages/Webkul/UpsShipping/src/Resources/lang/sin/app.php @@ -0,0 +1,23 @@ + [ + 'system' => [ + 'title' => 'මාතෘකාව', + 'description' => 'විස්තර', + 'status' => 'ස්ථානය', + 'ups' => 'UPS බෙහෙවිය', + 'ups-description' => 'UPS සමඟ අන්තර්ගත බෙහෙවිය, නිවැරදි හා හොඳයි තැනීම සහ ස්පීඩ් කරන්න.', + 'gateway-url' => 'ගේට්වේ URL', + 'user-id' => 'පරිශීලක හැඳුනුම්', + 'access-license-number' => 'ප්‍රවේශ සහිතවිය අංකය', + 'shipper' => 'හැපවුම් අංකය', + 'weight-unit' => 'බර ඒකකය', + 'password' => 'මුරපදය', + 'mode' => 'සංඛ්යාව', + 'container' => 'කොන්ටේනරය', + 'size' => 'තරම', + 'allowed-methods' => 'සමාවෙන සේවාවන්', + ], + ], +]; \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/src/Resources/lang/tr/app.php b/packages/Webkul/UpsShipping/src/Resources/lang/tr/app.php new file mode 100755 index 0000000..ad38620 --- /dev/null +++ b/packages/Webkul/UpsShipping/src/Resources/lang/tr/app.php @@ -0,0 +1,23 @@ + [ + 'system' => [ + 'title' => 'Başlık', + 'description' => 'Açıklama', + 'status' => 'Durum', + 'ups' => 'UPS Kargo', + 'ups-description' => 'UPS ile çevrimiçi kargo, Paketleri daha hızlı ve daha kolay bir şekilde gönderin ve teslim edin.', + 'gateway-url' => 'Ağ Geçidi URL', + 'user-id' => 'Kullanıcı Kimliği', + 'access-license-number' => 'Erişim Lisans Anahtarı', + 'shipper' => 'Gönderici Numarası', + 'weight-unit' => 'Ağırlık Birimi', + 'password' => 'Şifre', + 'mode' => 'Mod', + 'container' => 'Konteyner', + 'size' => 'Boyut', + 'allowed-methods' => 'İzin Verilen Hizmetler', + ], + ], +]; \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/src/Resources/lang/uk/app.php b/packages/Webkul/UpsShipping/src/Resources/lang/uk/app.php new file mode 100755 index 0000000..6696e1c --- /dev/null +++ b/packages/Webkul/UpsShipping/src/Resources/lang/uk/app.php @@ -0,0 +1,23 @@ + [ + 'system' => [ + 'title' => 'Назва', + 'description' => 'Опис', + 'status' => 'Статус', + 'ups' => 'Відправлення UPS', + 'ups-description' => 'Онлайн-доставка з UPS, Надсилайте та доставляйте пакети швидше та простіше, ніж будь-коли.', + 'gateway-url' => 'URL шлюзу', + 'user-id' => 'Ідентифікатор користувача', + 'access-license-number' => 'Ключ ліцензії доступу', + 'shipper' => 'Номер відправника', + 'weight-unit' => 'Одиниця ваги', + 'password' => 'Пароль', + 'mode' => 'Режим', + 'container' => 'Контейнер', + 'size' => 'Розмір', + 'allowed-methods' => 'Дозволені послуги', + ], + ], +]; \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/src/Resources/lang/zh_CN/app.php b/packages/Webkul/UpsShipping/src/Resources/lang/zh_CN/app.php new file mode 100755 index 0000000..ab90f59 --- /dev/null +++ b/packages/Webkul/UpsShipping/src/Resources/lang/zh_CN/app.php @@ -0,0 +1,23 @@ + [ + 'system' => [ + 'title' => '标题', + 'description' => '描述', + 'status' => '状态', + 'ups' => 'UPS 邮寄', + 'ups-description' => '使用 UPS 进行在线邮寄,更快、更轻松地发送和递送包裹。', + 'gateway-url' => '网关 URL', + 'user-id' => '用户 ID', + 'access-license-number' => '访问许可证密钥', + 'shipper' => '发货人编号', + 'weight-unit' => '重量单位', + 'password' => '密码', + 'mode' => '模式', + 'container' => '容器', + 'size' => '尺寸', + 'allowed-methods' => '允许的服务', + ], + ], +]; \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/src/Resources/views/configurations/field-type.blade.php b/packages/Webkul/UpsShipping/src/Resources/views/configurations/field-type.blade.php new file mode 100644 index 0000000..e1a57ce --- /dev/null +++ b/packages/Webkul/UpsShipping/src/Resources/views/configurations/field-type.blade.php @@ -0,0 +1,472 @@ +@inject('coreConfigRepository', 'Webkul\Core\Repositories\CoreConfigRepository') + +@php + $nameKey = $item['key'] . '.' . $field['name']; + + $name = $coreConfigRepository->getNameField($nameKey); + + $value = $coreConfigRepository->getValueByRepository($field); + + $validations = $coreConfigRepository->getValidations($field); + + $isRequired = Str::contains($validations, 'required') ? 'required' : ''; + + $channelLocaleInfo = $coreConfigRepository->getChannelLocaleInfo($field, $currentChannel->code, $currentLocale->code); +@endphp + + + + + @if ($field['type'] == 'depends') + @include('admin::configuration.dependent-field-type') + @else + +
+ + {!! __($field['title']) . ( __($field['title']) ? '' : '') !!} + + @if ( + ! empty($field['channel_based']) + && $channels->count() > 1 + ) + + {{ $currentChannel->name }} + + @endif + + @if (! empty($field['locale_based'])) + + {{ $currentLocale->name }} + + @endif + +
+ + + @if ($field['type'] == 'text') + + + + + @elseif ($field['type'] == 'password') + + + + + @elseif ($field['type'] == 'number') + + + + + @elseif ($field['type'] == 'color') + + + + + @elseif ($field['type'] == 'textarea') + + + + + @elseif ($field['type'] == 'editor') + + + + + @elseif ($field['type'] == 'select') + @php $selectedOption = core()->getConfigData($nameKey, $currentChannel->code, $currentLocale->code) ?? ''; @endphp + + + @if (isset($field['repository'])) + @foreach ($value as $key => $option) + + @endforeach + @else + @foreach ($field['options'] as $option) + @php + $value = ! isset($option['value']) ? null : ( $value = ! $option['value'] ? 0 : $option['value'] ); + @endphp + + + @endforeach + @endif + + + + @elseif ($field['type'] == 'multiselect') + @php $selectedOption = core()->getConfigData($nameKey, $currentChannel->code, $currentLocale->code) ?? ''; @endphp + + + + + + + + @elseif ($field['type'] == 'boolean') + @php + $selectedOption = core()->getConfigData($nameKey, $currentChannel->code, $currentLocale->code) ?? ($field['default_value'] ?? ''); + @endphp + + + + + + @elseif ($field['type'] == 'image') + + @php + $src = Storage::url(core()->getConfigData($nameKey, $currentChannel->code, $currentLocale->code)); + $result = core()->getConfigData($nameKey, $currentChannel->code, $currentLocale->code); + @endphp + +
+ @if ($result) + + + + @endif + + + +
+ + @if ($result) + + + + + @lang('admin::app.configuration.index.delete') + + + @endif + + @elseif ($field['type'] == 'file') + @php + $result = core()->getConfigData($nameKey, $currentChannel->code, $currentLocale->code); + $src = explode("/", $result); + $path = end($src); + @endphp + + @if ($result) + + + + @endif + + + + + @if ($result) +
+ + + + @lang('admin::app.configuration.index.delete') + +
+ @endif + + + @elseif ($field['type'] == 'country') + + + + + + @elseif ($field['type'] == 'state') + + + + @endif + + @endif + + @if (isset($field['info'])) + + @endif + + + + +
+ +@if ($field['type'] == 'country') + @pushOnce('scripts') + + + + + + + + @endPushOnce +@endif \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/tailwind.config.js b/packages/Webkul/UpsShipping/tailwind.config.js new file mode 100644 index 0000000..56c3a70 --- /dev/null +++ b/packages/Webkul/UpsShipping/tailwind.config.js @@ -0,0 +1,10 @@ +/** @type {import('tailwindcss').Config} */ +module.exports = { + content: ["./src/Resources/**/*.blade.php", "./src/Resources/**/*.js"], + + theme: { + extend: {}, + }, + + plugins: [], +}; \ No newline at end of file diff --git a/packages/Webkul/UpsShipping/vite.config.js b/packages/Webkul/UpsShipping/vite.config.js new file mode 100644 index 0000000..6f038dc --- /dev/null +++ b/packages/Webkul/UpsShipping/vite.config.js @@ -0,0 +1,43 @@ +import { defineConfig, loadEnv } from "vite"; +import laravel from "laravel-vite-plugin"; +import path from "path"; + +export default defineConfig(({ mode }) => { + const envDir = "../../../"; + + Object.assign(process.env, loadEnv(mode, envDir)); + + return { + build: { + emptyOutDir: true, + }, + + envDir, + + server: { + host: process.env.VITE_HOST || "localhost", + port: process.env.VITE_PORT || 5173, + }, + + plugins: [ + laravel({ + hotFile: "../../../public/ups-module-vite.hot", + publicDirectory: "../../../public", + buildDirectory: "themes/ups-module/build", + input: [ + "src/Resources/assets/css/app.css", + "src/Resources/assets/js/app.js", + ], + refresh: true, + }), + ], + + experimental: { + renderBuiltUrl(filename, { hostId, hostType, type }) { + if (hostType === "css") { + return path.basename(filename); + } + }, + }, + }; +}); \ No newline at end of file diff --git a/src/Carriers/Ups.php b/src/Carriers/Ups.php deleted file mode 100644 index 7419e86..0000000 --- a/src/Carriers/Ups.php +++ /dev/null @@ -1,94 +0,0 @@ -getConfigData('sales.carriers.ups.active')) - return false; - - $shippingMethods = []; - $rates = []; - $shippingHelper = app('Webkul\UpsShipping\Helpers\ShippingMethodHelper'); - $getCommonServices = app('Webkul\UpsShipping\Repositories\UpsRepository'); - $data = $shippingHelper->getAllCartProducts(); - $serviceData = $getCommonServices->getCommonMethods($data['response']); - - $shippingRate = session()->get('shipping_rates'); - - if ( isset($data['response']) && $data['response'] && !$data['errorResponse'] && !empty($serviceData) ) { - foreach ($serviceData as $key => $upsServices) { - $rate = 0; - $totalShippingCost = 0; - $upsMethod = $key; - $classId = ''; - - foreach ($upsServices as $upsRate) { - $classId = $upsRate['classId']; - $rate += $upsRate['rate'] * $upsRate['itemQuantity']; - $itemShippingCost = $upsRate['rate'] * $upsRate['itemQuantity']; - - if ( isset($rates[$key]) ) { - $rates[$key] = [ - 'amount' => core()->convertPrice($rates[$key]['amount'] + $itemShippingCost), - 'base_amount' => $rates[$key]['base_amount'] + $itemShippingCost - ]; - } else { - $rates[$key] = [ - 'amount' => core()->convertPrice($itemShippingCost), - 'base_amount' => $itemShippingCost - ]; - } - - $totalShippingCost += $itemShippingCost; - } - - $object = new CartShippingRate; - $object->carrier = 'ups'; - $object->carrier_title = $this->getConfigData('title') . ' (' . $this->getConfigData('description') . ')'; - $object->method = 'ups_' . $classId; - $object->method_title = $upsMethod; - $object->method_description = $this->getConfigData('title') . ' (' . $this->getConfigData('description') . ')'; - $object->is_calculate_tax = $this->getConfigData('is_calculate_tax'); - $object->price = core()->convertPrice($totalShippingCost); - $object->base_price = $totalShippingCost; - - $shippingRate = session()->get('shipping_rates'); - - if (! is_array($shippingRate)) { - $shippingRates['ups'] = $rates; - session()->put('shipping_rates', $shippingRates); - } else { - session()->put('shipping_rates.ups', $rates); - } - - array_push($shippingMethods, $object); - } - - return $shippingMethods; - } else { - return null; - } - } -} \ No newline at end of file diff --git a/src/Config/carriers.php b/src/Config/carriers.php deleted file mode 100644 index 515b479..0000000 --- a/src/Config/carriers.php +++ /dev/null @@ -1,11 +0,0 @@ - [ - 'code' => 'ups', - 'title' => 'UPS Shipping', - 'description' => 'UPS Shipping', - 'active' => true, - 'class' => 'Webkul\UpsShipping\Carriers\Ups', - ] -]; \ No newline at end of file diff --git a/src/Config/system.php b/src/Config/system.php deleted file mode 100644 index a876108..0000000 --- a/src/Config/system.php +++ /dev/null @@ -1,151 +0,0 @@ - 'sales.carriers.ups', - 'name' => 'ups::app.admin.system.ups', - 'sort' => 3, - 'fields' => [ - [ - 'name' => 'title', - 'title' => 'ups::app.admin.system.title', - 'type' => 'depends', - 'depend' => 'active:1', - 'validation' => 'required_if:active,1', - 'channel_based' => true, - 'locale_based' => true - ], [ - 'name' => 'description', - 'title' => 'ups::app.admin.system.description', - 'type' => 'textarea', - 'channel_based' => true, - 'locale_based' => true - ], [ - 'name' => 'active', - 'title' => 'ups::app.admin.system.status', - 'type' => 'boolean', - 'validation' => 'required', - 'channel_based' => true, - 'locale_based' => false - ], [ - 'name' => 'is_calculate_tax', - 'title' => 'admin::app.admin.system.calculate-tax', - 'type' => 'boolean', - 'validation' => 'required', - 'channel_based' => true, - 'locale_based' => false, - ], [ - 'name' => 'access_license_key', - 'title' => 'ups::app.admin.system.access-license-number', - 'type' => 'text', - 'validation' => 'required', - 'channel_based' => true, - 'locale_based' => false - ], [ - 'name' => 'user_id', - 'title' => 'ups::app.admin.system.user-id', - 'type' => 'text', - 'validation' => 'required', - 'channel_based' => true, - 'locale_based' => false - ], [ - 'name' => 'password', - 'title' => 'ups::app.admin.system.password', - 'type' => 'password', - 'validation' => 'required', - 'channel_based' => true, - 'locale_based' => false - ], [ - 'name' => 'shipper_number', - 'title' => 'ups::app.admin.system.shipper', - 'type' => 'text', - 'channel_based' => true, - 'locale_based' => false - ], [ - 'name' => 'container', - 'title' => 'ups::app.admin.system.container', - 'type' => 'select', - 'validation' => 'required', - 'options' => [ - [ - 'title' => 'Package', - 'value' => '02', - ], [ - 'title' => 'UPS Letter', - 'value' => '01' - ], [ - 'title' => 'UPS Tube', - 'value' => '03' - ], [ - 'title' => 'UPS Pak', - 'value' => '04' - ], [ - 'title' => 'UPS Express Box', - 'value' => '21' - ] - ], - 'channel_based' => true, - 'locale_based' => false - ], [ - 'name' => 'weight_unit', - 'title' => 'ups::app.admin.system.weight-unit', - 'type' => 'select', - 'validation' => 'required', - 'options' => [ - [ - 'title' => 'LBS', - 'value' => 'LBS' - ], [ - 'title' => 'KGS', - 'value' => 'KGS', - ] - ], - 'channel_based' => true, - 'locale_based' => false - ], [ - 'name' => 'services', - 'title' => 'ups::app.admin.system.allowed-methods', - 'type' => 'multiselect', - 'options' => [ - [ - 'title' => 'Next Day Air Early AM', - 'value' => '14', - ], [ - 'title' => 'Next Day Air', - 'value' => '01' - ], [ - 'title' => 'Next Day Air Saver', - 'value' => '13' - ], [ - 'title' => '2nd Day Air AM', - 'value' => '59' - ], [ - 'title' => '2nd Day Air', - 'value' => '02' - ], [ - 'title' => '3 Day Select', - 'value' => '12' - ], [ - 'title' => 'Ups Ground', - 'value' => '03' - ], [ - 'title' => 'UPS Worldwide Express', - 'value' => '07' - ], [ - 'title' => 'UPS Worldwide Express Plus', - 'value' => '54' - ], [ - 'title' => 'UPS Worldwide Expedited', - 'value' => '08' - ], [ - 'title' => 'UPS World Wide Saver', - 'value' => '65' - ], - - ], - 'channel_based' => true, - 'locale_based' => false - ] - ] - ], -]; \ No newline at end of file diff --git a/src/Helpers/ShippingMethodHelper.php b/src/Helpers/ShippingMethodHelper.php deleted file mode 100644 index 13e2bb4..0000000 --- a/src/Helpers/ShippingMethodHelper.php +++ /dev/null @@ -1,368 +0,0 @@ - 'Next Day Air', - '02' => '2nd Day Air', - '03' => 'Ups Ground', - '07' => 'Ups Worldwide Express', - '08' => 'Ups Worldwide Expedited', - '11' => 'Standard', - '12' => '3 Day Select', - '13' => 'Next Day Air Saver', - '14' => 'Next Day Air Early A.M.', - '54' => 'Ups Worldwide Express Plus', - '59' => '2nd Day Air A.M.', - '65' => 'UPS World Wide Saver', - '82' => 'Today Standard', - '83' => 'Today Dedicated Courier', - '84' => 'Today Intercity', - '85' => 'Today Express', - '86' => 'Today Express Saver' - ]; - - /** - * Cart Address Object - * - * @var object - */ - protected $cartAddress; - - /** - * Ups Repository Object - * - * @var object - */ - protected $upsRepository; - - /** - * RateServiceWsdl - * - * @var string - */ - protected $rateServiceWsdl; - - /** - * ShipServiceWsdl - * - * @var string - */ - protected $shipServiceWsdl; - - /** - * SellerRepository object - * - * @var object - */ - protected $channel; - - - /** - * Create a new controller instance. - * - * @param \Webkul\Checkout\Repositories\CartAddressRepository $cartAddress; - * @param \Webkul\Core\Repositories\ChannelRepository $channel - * @param \Webkul\Shipping\Repositories\UpsRepository $upsRepository; - */ - public function __construct( - CartAddress $cartAddress, - UpsRepository $upsRepository, - Channel $channel - ) - { - $this->_config = request('_config'); - - $this->cartAddress = $cartAddress; - - $this->upsRepository = $upsRepository; - - $this->channel = $channel; - } - - /** - * display methods - * - * @return array - */ - public function getAllCartProducts() - { - return $this->_createSoapClient() - ; - } - - /** - * Soap client for wsdl - * - * @param string $wsdl - * @param bool|int $trace - * @return \SoapClient - */ - protected function _createSoapClient() - { - $allServices = []; - $errorResponse = []; - $cart = Cart::getCart(); - $address = $cart->shipping_address; - $channelDetails = $this->channel->findOneWhere(['code' => core()->getCurrentChannelCode()]); - $sellerAdminServices = explode(",", core()->getConfigData('sales.carriers.ups.services')); - - foreach ($cart->items()->get() as $cartProduct) { - if ($cartProduct->product->getTypeInstance()->isStockable()) { - $weight = $this->getWeight($cartProduct->weight); - $countryId = core()->getConfigData('sales.shipping.origin.country'); - $zoneInformation = core()->getConfigData('sales.shipping.origin.state'); - $address1 = core()->getConfigData('sales.shipping.origin.address1'); - $city = core()->getConfigData('sales.shipping.origin.city'); - $accessKey = core()->getConfigData('sales.carriers.ups.access_license_key'); - $userId = core()->getConfigData('sales.carriers.ups.user_id'); - $password = core()->getConfigData('sales.carriers.ups.password'); - $url = core()->getConfigData('sales.carriers.ups.gateway_url'); - $shipperNumber = core()->getConfigData('sales.carriers.ups.shipper_number'); - $shipperNumber = $shipperNumber ? $shipperNumber: ''; - - // create a simple xml object for AccessRequest & RateRequest - $accessRequesttXML = new \SimpleXMLElement ( "" ); - $rateRequestXML = new \SimpleXMLElement ( "" ); - - // create AccessRequest XML - $accessRequesttXML->addChild ("AccessLicenseNumber", $accessKey); - $accessRequesttXML->addChild ("UserId", $userId); - $accessRequesttXML->addChild ("Password", $password); - - // create RateRequest XML - $request = $rateRequestXML->addChild ('Request'); - $request->addChild ("RequestAction", "Rate"); - $request->addChild ("RequestOption", "Shop"); - - $shipment = $rateRequestXML->addChild ('Shipment'); - $shipper = $shipment->addChild ('Shipper'); - $shipper->addChild ("Name", $channelDetails->name); - $shipper->addChild ("ShipperNumber", $shipperNumber); - - $shipperddress = $shipper->addChild ('Address'); - $shipperddress->addChild ("AddressLine1", $address1 ? $address1 : ''); - $shipperddress->addChild ("City", $city ? $city : ''); - $shipperddress->addChild ("PostalCode", core()->getConfigData('sales.shipping.origin.zipcode')); - $shipperddress->addChild ("CountryCode", $countryId); - - $shipFrom = $shipment->addChild ('ShipFrom'); - $shipFrom->addChild ("CompanyName", $channelDetails->hostname); - $shipFromAddress = $shipFrom->addChild ( 'Address'); - $shipFromAddress->addChild ("AddressLine1", $address1 ? $address1 : ''); - $shipFromAddress->addChild ("City", $city ? $city : ''); - $shipFromAddress->addChild ("StateProvinceCode", $zoneInformation); - $shipFromAddress->addChild ("PostalCode", core()->getConfigData('sales.shipping.origin.zipcode')); - $shipFromAddress->addChild ("CountryCode", $countryId); - - $shipTo = $shipment->addChild ( 'ShipTo'); - $shipTo->addChild ("CompanyName", $address->first_name . ' ' . $address->last_name); - $shipToAddress = $shipTo->addChild ( 'Address'); - $shipToAddress->addChild ("AddressLine1", $address->address1); - $shipToAddress->addChild ("City", $address->city); - if ( $address->country == 'PR' ) { - $shipToAddress->addChild ("PostalCode", '00'. $address->postcode); - } else { - $shipToAddress->addChild ("PostalCode", $address->postcode); - } - $shipToAddress->addChild ("CountryCode", $address->country); - $package = $shipment->addChild ('Package'); - $packageType = $package->addChild ('PackagingType'); - $packageType->addChild ("Code", core()->getConfigData('sales.carriers.ups.container')); - - $packageWeight = $package->addChild ('PackageWeight'); - $unitOfMeasurement = $packageWeight->addChild ('UnitOfMeasurement'); - $unitOfMeasurement->addChild ("Code", "LBS"); - $packageWeight->addChild ("Weight", $weight); - - $requestXML = $accessRequesttXML->asXML () . $rateRequestXML->asXML (); - - try { - $url = 'https://onlinetools.ups.com/ups.app/xml/Rate'; - $ch = curl_init(); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY); - curl_setopt($ch, CURLOPT_TIMEOUT, 30); - curl_setopt($ch, CURLOPT_POST, true); - curl_setopt($ch, CURLOPT_URL, $url); - curl_setopt($ch, CURLOPT_HTTPHEADER, array( - "Content-type: text/xml", - "Accept: text/xml", - "Cache-Control: no-cache", - "Pragma: no-cache", - )); - curl_setopt($ch, CURLOPT_POSTFIELDS, $requestXML); - $response = curl_exec($ch); - curl_close($ch); - - $upsServiceArray = simplexml_load_string($response); - $upsServices = json_decode(json_encode($upsServiceArray)); - - if ($response) { - if ( isset($upsServices->Response->ResponseStatusCode) - && $upsServices->Response->ResponseStatusCode == 1 ) { - - if ( isset($upsServices->RatedShipment) && $upsServices->RatedShipment ) { - - foreach ($upsServices->RatedShipment as $services) { - $serviceCode = $services->Service->Code; - - if ( !empty($sellerAdminServices) && in_array($serviceCode, $sellerAdminServices) && isset($this->services[$serviceCode]) ) { - - $cartProductServices[$this->services[$serviceCode]] = [ - 'classId' => $serviceCode, - 'rate' => $services->TotalCharges->MonetaryValue, - 'currency' => $services->TotalCharges->CurrencyCode, - 'weight' => $services->BillingWeight->Weight, - 'weightUnit' => $services->BillingWeight->UnitOfMeasurement->Code, - 'itemQuantity' => $cartProduct->quantity - ]; - } - } - - if ( !empty($cartProductServices)) { - $allServices[] = $cartProductServices; - } - } - } else { - if ( isset($upsServices->Response->ResponseStatusCode) && isset($upsServices->Response->Error->ErrorDescription) ) { - $this->getErrorLog($upsServices->Response->Error->ErrorDescription); - $errorResponse[] = $upsServices->Response->Error->ErrorDescription; - } - } - } - } catch (\Exception $e) { - $this->getErrorLog($e->getMessage()); - $errorResponse[] = $e->getMessage(); - } - } - } - - $responses = [ - 'response' => $allServices, - 'errorResponse' => $errorResponse - ]; - - return $responses; - } - - - /** - * Map service code - * - * @param $serviceCode - */ - protected function getServiceName($serviceCode) - { - $mapServices = [ - '01' => 'Next Day Air', - '02' => '2nd Day Air', - '03' => 'Ups Ground', - '07' => 'Ups Worldwide Express', - '08' => 'Ups Worldwide Expedited', - '11' => 'Standard', - '12' => '3 Day Select', - '13' => 'Next Day Air Saver', - '14' => 'Next Day Air Early A.M.', - '54' => 'Ups Worldwide Express Plus', - '59' => '2nd Day Air A.M.', - '65' => 'UPS World Wide Saver', - '82' => 'Today Standard', - '83' => 'Today Dedicated Courier', - '84' => 'Today Intercity', - '85' => 'Today Express', - '86' => 'Today Express Saver', - '03' => 'Ups Ground', - - ]; - - foreach ($mapServices as $key => $service) { - if ($key == $serviceCode) { - return $service; - } - } - - return $serviceCode; - } - - /** - * convert current weight unit to LBS - * - * @param string $weight - **/ - public function getWeight($weight) - { - $coreWeightUnit = strtoupper(core()->getConfigData('general.general.locale_options.weight_unit')); - $upsWeightUnit = strtoupper(core()->getConfigData('sales.carriers.ups.weight_unit')); - $convertedWeight = ''; - - if ($coreWeightUnit == 'LBS') { - if ( $upsWeightUnit == 'LBS') { - $convertedWeight = $weight; - } else { - //kgs to lbs - $convertedWeight = $weight/0.45359237; - } - } else { - $convertedWeight = $weight/0.45359237; - } - - return $convertedWeight; - } - - /** - * Get The Current Error - * - * @param string $error - **/ - public function getErrorLog($errors) { - if ( isset($errors->Response->Error) ) { - - if (gettype($errors->Response->Error) == 'array') { - - foreach ($errors->Response->Error as $errorLog) - { - $exception[] = $errorLog->ErrorDescription; - } - - $status = $errors->Response->ResponseStatusDescription; - } else { - $status = $errors->Response->Error->ErrorSeverity; - - $exception[] = $errors->Response->Error->ErrorDescription; - } - - $logs = ['status' => $status, 'description' => $exception]; - - $shippingLog = new Logger('shipping'); - $shippingLog->pushHandler(new StreamHandler(storage_path('logs/ups.log')), Logger::INFO); - $shippingLog->info('shipping', $logs); - - return true; - } else { - return false; - } - } -} \ No newline at end of file diff --git a/src/Repositories/UpsRepository.php b/src/Repositories/UpsRepository.php deleted file mode 100644 index f63fdbd..0000000 --- a/src/Repositories/UpsRepository.php +++ /dev/null @@ -1,140 +0,0 @@ - - * @copyright 2019 Webkul Software Pvt Ltd (http://www.webkul.com) - */ -class UpsRepository -{ - /** - * SellerProduct Repository object - * - * @var array - */ - protected $productRepository; - - - /** - * Get the Admin Product - * - * @return mixed - */ - public function getSellerAdminData($cartItems) { - $adminProducts = []; - foreach ($cartItems as $item) { - array_push($adminProducts, $item); - } - return $adminProducts; - } - - /** - * Get the Allowde Services - * @param $allowedServices - * @return $secvices - */ - public function validateAllowedMethods($service, $allowedServices) - { - $count = 0; - $totalCount = count($allowedServices); - - foreach ($allowedServices as $methods) { - if ( in_array($service, $methods) ) { - $count += 1; - } - } - if ( $count == $totalCount ) { - return true; - } else { - return false; - } - } - - /** - * Get the Common Services for all the cartProduct - * @param $allServices - */ - public function getAllowedMethods($allServices) { - - $allowedServices = explode(",", core()->getConfigData('sales.carriers.ups.services')); - - foreach ($allServices as $services) { - $allowedMethod =[]; - foreach ($services as $service) { - - foreach ($service as $serviceType =>$upsService) { - if (in_array($serviceType , $allowedServices)) { - $allowedMethod[] = [ - $serviceType => $upsService - ]; - } else { - $notAllowed[] = [ - $serviceType => $upsService - ]; - } - } - } - - if ($allowedMethod == null) { - continue; - } else { - $allowedMethods[] = $allowedMethod; - } - - } - - if (isset($allowedMethods)) { - - return $this->getCommonMethods($allowedMethods); - } else { - return false; - } - } - - - /** - * get the Common method - * - * @param $Methods - */ - public function getCommonMethods($methods) - { - $avilableServicesArray = []; - $countMethods = count($methods); - - foreach ($methods as $fedexMethods) { - foreach ($fedexMethods as $key => $fedexMethod) { - $avilableServicesArray[] = $key; - } - } - - $countServices = array_count_values($avilableServicesArray); - $finalServices = []; - - foreach ($countServices as $serviceType => $servicesCount) { - - foreach ($methods as $fedexMethods) { - foreach ($fedexMethods as $type => $fedexMethod) { - if ($serviceType == $type && $servicesCount == $countMethods) { - - $finalServices[$serviceType][] =$fedexMethod; - } - } - } - - if ($finalServices == null) { - continue; - } - } - - if (!empty($finalServices)) { - return $finalServices; - } else { - return false; - } - } -} - diff --git a/src/Resources/lang/en/app.php b/src/Resources/lang/en/app.php deleted file mode 100644 index d6a5aba..0000000 --- a/src/Resources/lang/en/app.php +++ /dev/null @@ -1,22 +0,0 @@ - [ - 'system' => [ - 'title' => 'Title', - 'description' => 'Description', - 'status' => 'Status', - 'ups' => 'UPS Shipping', - 'gateway-url' => 'Gateway URL', - 'user-id' => 'User ID' , - 'access-license-number' => 'Access License Key', - 'shipper' => 'Shipper Number', - 'weight-unit' => 'Weight Unit', - 'password' => 'Password', - 'mode' => 'Mode', - 'container' => 'Container', - 'size' => 'Size', - 'allowed-methods' => 'Allowed Services', - ], - ] -]; \ No newline at end of file