diff --git a/uafrica/Customshipping/Block/System/Config/Form/Field/Version.php b/Block/System/Config/Form/Field/Version.php similarity index 100% rename from uafrica/Customshipping/Block/System/Config/Form/Field/Version.php rename to Block/System/Config/Form/Field/Version.php diff --git a/uafrica/Customshipping/Helper/Data.php b/Helper/Data.php similarity index 100% rename from uafrica/Customshipping/Helper/Data.php rename to Helper/Data.php diff --git a/uafrica/Customshipping/Model/Carrier/Customshipping.php b/Model/Carrier/Customshipping.php similarity index 90% rename from uafrica/Customshipping/Model/Carrier/Customshipping.php rename to Model/Carrier/Customshipping.php index c79ed4a8f965fff6acb95875c98758f05f865fb2..306e2f05d4aec66d82f57621423cb8a44897f706 100644 --- a/uafrica/Customshipping/Model/Carrier/Customshipping.php +++ b/Model/Carrier/Customshipping.php @@ -51,7 +51,6 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ /** Tracking Endpoint */ const TRACKING = 'https://api.dev.ship.uafrica.com/tracking?channel=localhost&tracking_reference='; /*** RATES API Endpoint*/ -// const RATES_ENDPOINT = 'https://8390956f-c00b-497d-8742-87b1d6305bd2.mock.pstmn.io/putrates'; const RATES_ENDPOINT = 'https://api.dev.ship.uafrica.com/rates-at-checkout/woocommerce'; /** @@ -61,21 +60,6 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ */ protected $_code = self::CODE; - /** - * Types of rates, order is important - * - * @var array - */ - protected $_ratesOrder = [ - 'RATED_ACCOUNT_PACKAGE', - 'PAYOR_ACCOUNT_PACKAGE', - 'RATED_ACCOUNT_SHIPMENT', - 'PAYOR_ACCOUNT_SHIPMENT', - 'RATED_LIST_PACKAGE', - 'PAYOR_LIST_PACKAGE', - 'RATED_LIST_SHIPMENT', - 'PAYOR_LIST_SHIPMENT', - ]; /** * Rate request data @@ -91,27 +75,6 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ */ protected $_result = null; - /** - * Path to wsdl file of rate service - * - * @var string - */ - protected $_rateServiceWsdl; - - /** - * Path to wsdl file of ship service - * - * @var string - */ - protected $_shipServiceWsdl = null; - - /** - * Path to wsdl file of track service - * - * @var string - */ - protected $_trackServiceWsdl = null; - /** * Container types that could be customized for uAfrica carrier * @@ -270,16 +233,13 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ $destCountry = $request->getDestCountryId(); $destRegion = $request->getDestRegionCode(); $destCity = $request->getDestCity(); - $destStreet = $request->getDestStreet(); + $destStreet = $request->getDestStreet() !== null ? str_replace("\n", ' ', $request->getDestStreet()) : ''; $destStreet1 = $destStreet; - $destStreet2 = $destStreet; + // $destStreet2 = $destStreet; //Get all the origin data from the request /** Origin Information */ - list($originStreet, $originRegion, $originCity, $originStreet1, $originStreet2, $storeName, $storeEmail, $storePhoneNumber, $baseIdentifier) = $this->storeInformation(); - - - + list($originStreet, $originRegion, $originCountry, $originCity, $originStreet1, $originStreet2, $storeName, $baseIdentifier) = $this->storeInformation(); $items = $request->getAllItems(); @@ -287,18 +247,10 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ foreach ($items as $item) { $itemsArray[] = [ - 'name' => $item->getName(), 'sku' => $item->getSku(), 'quantity' => $item->getQty(), 'price' => $item->getPrice(), 'grams' => $item->getWeight() * 1000, - 'requires_shipping' => $item->getIsVirtual(), - 'taxable' => true, - 'fulfillment_service' => 'manual', - 'properties' => [], - 'vendor' => $item->getName(), - 'product_id' => $item->getProductId(), - 'variant_id' => $item->getProduct()->getId() ]; } @@ -306,38 +258,24 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ 'identifier' => $baseIdentifier, 'rate' => [ 'origin' => [ - 'country' => 'ZA', - 'postal_code' => $originStreet, - 'province' => $originRegion, - 'city' => $originCity, - 'name' => $storeName, + 'company' => $storeName, 'address1' => $originStreet1, 'address2' => $originStreet2, - 'address3' => '', - 'phone' => $storePhoneNumber, - 'fax' => '', - 'email' => $storeEmail, - 'address_type' => '', - 'company_name' => $storeName + 'city' => $originCity, + 'province' => $originRegion, + 'country_code' => $originCountry, + 'postal_code' => $originStreet, ], 'destination' => [ - 'country' => $destCountry, - 'postal_code' => $destination, - 'province' => $destRegion, - 'city' => $destCity, - 'name' => 'Brian Singh', + 'company' => '', // TODO :: Add this if available 'address1' => $destStreet1, - 'address2' => $destStreet2, - 'address3' => '', - 'phone' => '', - 'fax' => '', - 'email' => '', - 'address_type' => '', - 'company_name' => '' + 'address2' => '', + 'city' => $destCity, + 'province' => $destRegion, + 'country_code' => $destCountry, + 'postal_code' => $destination, ], 'items' => $itemsArray, - 'currency' => '', - 'locale' => 'en-PT' ] ]; @@ -346,7 +284,6 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ return $result; } - /** * @return array */ @@ -354,6 +291,10 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ { /** Store Origin details */ + $originCountry = $this->_scopeConfig->getValue( + 'general/store_information/country_id', + ScopeInterface::SCOPE_STORE + ); $originRegion = $this->_scopeConfig->getValue( 'general/store_information/region_id', ScopeInterface::SCOPE_STORE @@ -383,18 +324,13 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ ScopeInterface::SCOPE_STORE ); - $storeEmail = $this->_scopeConfig->getValue( - 'general/store_information/email', - ScopeInterface::SCOPE_STORE - ); - $storePhoneNumber = $this->_scopeConfig->getValue( 'general/store_information/phone', ScopeInterface::SCOPE_STORE ); $baseIdentifier = $this->getBaseUrl(); - return array($originStreet, $originRegion, $originCity, $originStreet1, $originStreet2, $storeName, $storeEmail, $storePhoneNumber, $baseIdentifier); + return array($originStreet, $originRegion, $originCountry, $originCity, $originStreet1, $originStreet2, $storeName, $baseIdentifier); } @@ -541,7 +477,6 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ */ protected function _parseTrackingResponse($trackingValue) { - $result = $this->getResult(); $carrierTitle = $this->getConfigData('title'); $counter = 0; @@ -560,7 +495,7 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ $counter ++; } - // no available tracking details + //Tracking Details Not Available if (!$counter) { $this->appendTrackingError( $trackingValue, @@ -700,7 +635,7 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ * @return array * @SuppressWarnings(PHPMD.CyclomaticComplexity) * @SuppressWarnings(PHPMD.NPathComplexity) - */ + **/ private function processTrackingDetails($trackInfo): array { $result = [ @@ -726,7 +661,7 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ private function appendTrackingError($trackingValue, $errorMessage) { $error = $this->_trackErrorFactory->create(); - $error->setCarrier('uafrica'); + $error->setCarrier(self::CODE); $error->setCarrierTitle($this->getConfigData('title')); $error->setTracking($trackingValue); $error->setErrorMessage($errorMessage); @@ -808,7 +743,7 @@ class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\ foreach ($rates['rates'] as $code => $title) { $method = $this->_rateMethodFactory->create(); - $method->setCarrier('uafrica'); + $method->setCarrier(self::CODE); if ($this->getConfigData('additional_info') == 1) { $min_delivery_date = $this->getWorkingDays(date('Y-m-d'), $title['min_delivery_date']); $max_delivery_date = $this->getWorkingDays(date('Y-m-d'), $title['max_delivery_date']); diff --git a/uafrica/Customshipping/Model/Source/Dropoff.php b/Model/Source/Dropoff.php similarity index 100% rename from uafrica/Customshipping/Model/Source/Dropoff.php rename to Model/Source/Dropoff.php diff --git a/uafrica/Customshipping/Model/Source/Freemethod.php b/Model/Source/Freemethod.php similarity index 100% rename from uafrica/Customshipping/Model/Source/Freemethod.php rename to Model/Source/Freemethod.php diff --git a/uafrica/Customshipping/Model/Source/Generic.php b/Model/Source/Generic.php similarity index 100% rename from uafrica/Customshipping/Model/Source/Generic.php rename to Model/Source/Generic.php diff --git a/uafrica/Customshipping/Model/Source/Method.php b/Model/Source/Method.php similarity index 100% rename from uafrica/Customshipping/Model/Source/Method.php rename to Model/Source/Method.php diff --git a/uafrica/Customshipping/Model/Source/Packaging.php b/Model/Source/Packaging.php similarity index 100% rename from uafrica/Customshipping/Model/Source/Packaging.php rename to Model/Source/Packaging.php diff --git a/uafrica/Customshipping/Model/Source/Unitofmeasure.php b/Model/Source/Unitofmeasure.php similarity index 100% rename from uafrica/Customshipping/Model/Source/Unitofmeasure.php rename to Model/Source/Unitofmeasure.php diff --git a/uafrica/Customshipping/Plugin/Block/DataProviders/Tracking/ChangeTitle.php b/Plugin/Block/DataProviders/Tracking/ChangeTitle.php similarity index 100% rename from uafrica/Customshipping/Plugin/Block/DataProviders/Tracking/ChangeTitle.php rename to Plugin/Block/DataProviders/Tracking/ChangeTitle.php diff --git a/uafrica/Customshipping/Plugin/Block/Tracking/PopUpDeliveryDate.php b/Plugin/Block/Tracking/PopUpDeliveryDate.php similarity index 100% rename from uafrica/Customshipping/Plugin/Block/Tracking/PopUpDeliveryDate.php rename to Plugin/Block/Tracking/PopUpDeliveryDate.php diff --git a/README.md b/README.md deleted file mode 100644 index 5e87fd814b6e4112483d5e22dab82fd46e92b980..0000000000000000000000000000000000000000 --- a/README.md +++ /dev/null @@ -1,129 +0,0 @@ - - -# Magento 2 uAfrica Shipping Extension - -## Introduction - -A complete guide to install Magento uAfrica Shipping extension in Magento 2. - -## Features ->This extension allows you to get real-time shipping rates from BobGo shipping services and display them to your customers during checkout. - ->This extension also allows you to track shipments and get delivery status updates from BobGo shipping services. - -## How to install Magento 2 Bobgo Shipping Extension - -### Option 1 (recommended): Install via composer - -Run the following command in Magento 2 root folder:</br> - - ->_Note: You must have composer installed on your server & at this point this option_ - -#### 1. Execute the following command to install the module: - -``` -composer require uafrica/bobgo -``` -#### 2. Enter following commands to enable the module: - -``` -php bin/magento module:enable uafrica_Customshipping -php bin/magento cache:clean -php bin/magento cache:flush -php bin/magento setup:upgrade -php bin/magento setup:di:compile -php bin/magento setup:static-content:deploy -``` - - -### Option 2: Install via zip file - -1. Download the extension zip file from the link below: </br> - -<a href="https://github.com/uafrica/magento-uafrica-shipping-extension/archive/refs/heads/main.zip"> Download Magento 2 uAfrica Shipping Extension </a> - -2. Unzip the file and copy contents ->**{Magento root}**`/app/code/`**{Paste here}** - -**It should look like this:** </br> ->{Magento root}/app/code/uafrica/Customshipping/ - -3. Go to Magento root folder and run upgrade `bin/magento setup:upgrade` command line to install `uafrica_Customshipping`: </br> -``` -Bin/magento cache:clean -Bin/magento cache:flush -Bin/magento setup:upgrade -Bin/magento setup:di:compile -``` -_____________________________________________________________________________________________________________________ -### After installation - -## How to configure Magento 2 uAfrica Shipping Extension - -### ✓ Step 1: Create an account on Bobgo - -You need to create an account on Bobgo to get your Store Identified by the API. - -Please visit [Bobgo](https://uafrica.co.za) to create an account. - -### ✓ Step 2: Login to Magento Admin - -1. Click on UAFRICA > bobGo > Enabled for Checkout > Yes </br> - - -2. and go to `Stores > Configuration > Sales > Delivery Methods` to configure the extension. - -[//]: # (### ✓ Step 3: Configure Bobgo Shipping Extension) - -[//]: # () -[//]: # (1. Select `Bobgo` as shipping method) - -[//]: # (2. Enter API key and API secret) - -[//]: # (3. Select `Enable` to enable the extension) - -[//]: # (4. Select `Enable Debug Mode` to enable debug mode) - -[//]: # (5. Click `Save Config`) - -[//]: # (6. Flush cache (System > Cache Management) and reindex (System > Index Management)) - -[//]: # (7. Clear generated files(`rm -rf var/generation/*`)) - -[//]: # (8. Reindex data (`php bin/magento indexer:reindex`)) - -[//]: # (9. Deploy static content (`php bin/magento setup:static-content:deploy`)) - -[//]: # (10. Run `php bin/magento cache:clean`) - -[//]: # (11. Run `php bin/magento cache:flush`) - -[//]: # (12. Run `php bin/magento setup:upgrade`) - -[//]: # (13. Run `php bin/magento setup:di:compile`) - -[//]: # (14. Run `php bin/magento setup:static-content:deploy`) - -## How it works - - -## How to use Magento 2 Bobgo Shipping Extension (carrier) to Ship Orders - -### ✓ Step 1: Add products to cart(Checkout) - ->1. Add products to cart ->2. Go to checkout page ->3. Select shipping address ->4. BobGo will collect Shipping Rates that cart ->5. Select shipping method ->6. Place order - -### ✓ Step 1: Create shipment (Admin) -`Sales > Orders > View Order > Ship` - ->1. Go to `Sales > Orders` in Magento Admin ->2. Select an order ->3. Click `Ship` button ->4. Select `uAfrica` as shipping method ->5. Click `Submit Shipment` button diff --git a/uafrica/Customshipping/Readme.md b/Readme.md similarity index 100% rename from uafrica/Customshipping/Readme.md rename to Readme.md diff --git a/uafrica/Customshipping/composer.json b/composer.json similarity index 100% rename from uafrica/Customshipping/composer.json rename to composer.json diff --git a/uafrica/Customshipping/composer.lock b/composer.lock similarity index 100% rename from uafrica/Customshipping/composer.lock rename to composer.lock diff --git a/uafrica/Customshipping/etc/adminhtml/system.xml b/etc/adminhtml/system.xml similarity index 100% rename from uafrica/Customshipping/etc/adminhtml/system.xml rename to etc/adminhtml/system.xml diff --git a/uafrica/Customshipping/etc/config.xml b/etc/config.xml similarity index 100% rename from uafrica/Customshipping/etc/config.xml rename to etc/config.xml diff --git a/uafrica/Customshipping/etc/module.xml b/etc/module.xml similarity index 100% rename from uafrica/Customshipping/etc/module.xml rename to etc/module.xml diff --git a/uafrica/Customshipping/i18n/en_US.csv b/i18n/en_US.csv similarity index 100% rename from uafrica/Customshipping/i18n/en_US.csv rename to i18n/en_US.csv diff --git a/uafrica/Customshipping/registration.php b/registration.php similarity index 100% rename from uafrica/Customshipping/registration.php rename to registration.php diff --git a/uafrica/Customshipping/vendor/autoload.php b/vendor/autoload.php similarity index 100% rename from uafrica/Customshipping/vendor/autoload.php rename to vendor/autoload.php diff --git a/uafrica/Customshipping/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php similarity index 100% rename from uafrica/Customshipping/vendor/composer/ClassLoader.php rename to vendor/composer/ClassLoader.php diff --git a/uafrica/Customshipping/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php similarity index 100% rename from uafrica/Customshipping/vendor/composer/InstalledVersions.php rename to vendor/composer/InstalledVersions.php diff --git a/uafrica/Customshipping/vendor/composer/LICENSE b/vendor/composer/LICENSE similarity index 100% rename from uafrica/Customshipping/vendor/composer/LICENSE rename to vendor/composer/LICENSE diff --git a/uafrica/Customshipping/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php similarity index 100% rename from uafrica/Customshipping/vendor/composer/autoload_classmap.php rename to vendor/composer/autoload_classmap.php diff --git a/uafrica/Customshipping/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php similarity index 100% rename from uafrica/Customshipping/vendor/composer/autoload_namespaces.php rename to vendor/composer/autoload_namespaces.php diff --git a/uafrica/Customshipping/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php similarity index 100% rename from uafrica/Customshipping/vendor/composer/autoload_psr4.php rename to vendor/composer/autoload_psr4.php diff --git a/uafrica/Customshipping/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php similarity index 100% rename from uafrica/Customshipping/vendor/composer/autoload_real.php rename to vendor/composer/autoload_real.php diff --git a/uafrica/Customshipping/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php similarity index 100% rename from uafrica/Customshipping/vendor/composer/autoload_static.php rename to vendor/composer/autoload_static.php diff --git a/uafrica/Customshipping/vendor/composer/installed.json b/vendor/composer/installed.json similarity index 100% rename from uafrica/Customshipping/vendor/composer/installed.json rename to vendor/composer/installed.json diff --git a/uafrica/Customshipping/vendor/composer/installed.php b/vendor/composer/installed.php similarity index 100% rename from uafrica/Customshipping/vendor/composer/installed.php rename to vendor/composer/installed.php diff --git a/uafrica/Customshipping/view/frontend/layout/checkout_cart_index.xml b/view/frontend/layout/checkout_cart_index.xml similarity index 100% rename from uafrica/Customshipping/view/frontend/layout/checkout_cart_index.xml rename to view/frontend/layout/checkout_cart_index.xml diff --git a/uafrica/Customshipping/view/frontend/layout/checkout_index_index.xml b/view/frontend/layout/checkout_index_index.xml similarity index 100% rename from uafrica/Customshipping/view/frontend/layout/checkout_index_index.xml rename to view/frontend/layout/checkout_index_index.xml diff --git a/uafrica/Customshipping/view/frontend/web/js/model/shipping-rates-validation-rules.js b/view/frontend/web/js/model/shipping-rates-validation-rules.js similarity index 100% rename from uafrica/Customshipping/view/frontend/web/js/model/shipping-rates-validation-rules.js rename to view/frontend/web/js/model/shipping-rates-validation-rules.js diff --git a/uafrica/Customshipping/view/frontend/web/js/model/shipping-rates-validator.js b/view/frontend/web/js/model/shipping-rates-validator.js similarity index 100% rename from uafrica/Customshipping/view/frontend/web/js/model/shipping-rates-validator.js rename to view/frontend/web/js/model/shipping-rates-validator.js diff --git a/uafrica/Customshipping/view/frontend/web/js/view/shipping-rates-validation.js b/view/frontend/web/js/view/shipping-rates-validation.js similarity index 100% rename from uafrica/Customshipping/view/frontend/web/js/view/shipping-rates-validation.js rename to view/frontend/web/js/view/shipping-rates-validation.js