diff --git a/uafrica/Customshipping/Model/Carrier/Customshipping.php b/uafrica/Customshipping/Model/Carrier/Customshipping.php index 90d34817eaf4428f2236569025eb9070ab8e4ad2..cafd009799f8628a8eb847006a02e868ea0e36ec 100644 --- a/uafrica/Customshipping/Model/Carrier/Customshipping.php +++ b/uafrica/Customshipping/Model/Carrier/Customshipping.php @@ -20,6 +20,7 @@ use Magento\Framework\Controller\ResultInterface; use Magento\Framework\Controller\Result\JsonFactory; use Magento\Framework\HTTP\Client\Curl; use Magento\Framework\HTTP\Client\CurlFactory; +use function Safe\swoole_event_defer; /** * @category uafrica @@ -114,20 +115,106 @@ class Customshipping extends AbstractCarrier implements CarrierInterface { return true; } - //Make getracking available with fake data + /** * @param string $tracking * @return DataObject */ public function getTrackingInfo($tracking): DataObject - { - // $result = $this->_trackFactory->create(); + { + //Not Used Yet On This Phase of Development + // $result = $this->_trackFactory->create(); $result = new DataObject(); + $result->setUrl('https://api.dev.ship.uafrica.com/tracking?channel=localhost&tracking_reference=UADPCTGF'); + $result->setTracking($tracking); + $result->setCarrierTitle($this->getConfigData('title')); + + //Perfom curl request to get tracking info from uAfrica API + $this->curl->get('https://api.dev.ship.uafrica.com/tracking?channel=localhost&tracking_reference=UADPCTGF'); + + $response = $this->curl->getBody(); + + $response = json_decode($response, true); + + $result->addData((array)$response); + /**1. Image to be dynamic in the next phase + * 2. Tracking status to be dynamic in the next phase + * 3. This method feels hacky, not sure if I will need to refactor, but it works for now I am up for suggestions + */ + + //Todo: Add Image to the result object + echo "<pre>"; + print_r(" + <img src='https://ik.imagekit.io/z1viz85yxs/dev-v3/provider-logos/devpanda_logo.png' alt='Dev Panda' width='100' height='100'> + + <table '> + <tr> + <th>Order Number</th> + <th>Order Date</th> + <th>Order Status</th> + </tr> + <tr> + <td>".$response[0]['order_number']."</td> + <td>".$response[0]['shipment_time_created']."</td> + <td>".$response[0]['status_friendly']."</td> + </tr> + </table> + + <h4>Tracking</h4> + <table> + <tr> + <th>Tracking Number</th> + <th>Tracking Status</th> + <th>Tracking Date</th> + </tr> + <tr> + <td>".$response[0]['shipment_tracking_reference']."</td> + <td>".$response[0]['status_friendly']."</td> + <td>".$response[0]['last_checkpoint_time']."</td> + </tr> + </table> + + "); + + print_r(" <h4>Checkpoints</h4> + <table> + <tr> + <th>Status</th> + <th>Status Friendly</th> + <th>Country</th> + <th>Zone</th> + <th>City</th> + <th>Zip</th> + <th>Location</th> + <th>Message</th> + <th>Time</th> + </tr>" + ); + foreach ($response[0]['checkpoints'] as $checkpoint) { + print_r("<tr> + <td>" . $checkpoint['status'] . "</td> + <td>" . $checkpoint['status_friendly'] . "</td> + <td>" . $checkpoint['country'] . "</td> + <td>" . $checkpoint['zone'] . "</td> + <td>" . $checkpoint['city'] . "</td> + <td>" . $checkpoint['zip'] . "</td> + <td>" . $checkpoint['location'] . "</td> + <td>" . $checkpoint['message'] . "</td> + <td>" . $checkpoint['time'] . "</td> + </tr> + "); + + } + print_r("</table>"); + + echo "</pre>"; + return $result; } + //rewrite function to include json response with formatted data /** * Collect and get rates for storefront diff --git a/uafrica/Customshipping/Readme.md b/uafrica/Customshipping/Readme.md index 7d894ccb566462edf3b57b1202cb1549ad0542ae..57e405e56ffa03f7dd1d1b52c4ee587550e9d24e 100644 --- a/uafrica/Customshipping/Readme.md +++ b/uafrica/Customshipping/Readme.md @@ -4,14 +4,23 @@ ## Introduction -Magento 2 Bobgo Shipping Extension is a Magento 2 extension that allows you to integrate your Magento 2 store with Bobgo shipping service. This extension allows you to get real-time shipping rates from Bobgo shipping service and display them to your customers during checkout. This extension also allows you to print shipping labels and track shipments. +Magento 2 Bobgo Shipping Extension is a Magento 2 extension that allows you to integrate your Magento 2 store with Bobgo shipping service. + +## Features +This extension allows you to get real-time shipping rates from Bobgo shipping service and display them to your customers during checkout. + + +This extension also allows you to track shipments. ## How to install Magento 2 Bobgo Shipping Extension ### ✓ Install via composer (recommend) Run the following command in Magento 2 root folder:</br> -<Note: You must have composer installed on your server & at this point this option does not work> + + +<_Note: You must have composer installed on your server & at this point this option does not work, +, option working is manual, although everything is set and ready for installation through composer from https://packagist.org/_ > ``` composer require uafrica/bobgo @@ -22,14 +31,21 @@ php bin/magento setup:static-content:deploy ### ✓ Install via zip file 1. Download the extension + 2. Unzip the file + 3. Create a folder {Magento root}/app/code/uafrica/Customshipping -4. Copy the content from the unzip folder -5. Go to Magento root folder and run upgrade command line to install `uafrica_Customshipping`: + +4. Copy the content from the unzip folder(Registration.php, etc, view, etc) to {Magento root}/app/code/uafrica/Customshipping) + + +5. Go to Magento root folder and run upgrade `bin/magento setup:upgrade` command line to install `uafrica_Customshipping`: ``` -php bin/magento setup:upgrade -php bin/magento setup:static-content:deploy +Bin/magento cache:clean +Bin/magento cache:flush +Bin/magento setup:upgrade +Bin/magento setup:di:compile ``` ## How to configure Magento 2 Bobgo Shipping Extension @@ -48,15 +64,24 @@ Login to Magento Admin and go to `Stores > Configuration > Sales > Delivery Meth 1. Select `Bobgo` as shipping method 2. Enter API key and API secret 3. Select `Enable` to enable the extension -4. Select `Enable Test Mode` to enable test mode -5. Select `Enable Debug Mode` to enable debug mode -6. Click `Save Config` -7. Flush cache (System > Cache Management) and reindex (System > Index Management) -8. Clear generated files(`rm -rf var/generation/*`) -9. Reindex data (`php bin/magento indexer:reindex`) -10. Deploy static content (`php bin/magento setup:static-content:deploy`) -11. Run `php bin/magento cache:clean` -12. Run `php bin/magento cache:flush` -13. Run `php bin/magento setup:upgrade` -14. Run `php bin/magento setup:di:compile` -15. Run `php bin/magento setup:static-content:deploy` +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 to use Magento 2 Bobgo Shipping Extension (carrier) to ship orders + +### ✓ Step 1: Create shipment + +1. Go to `Sales > Orders` in Magento Admin +2. Select an order +3. Click `Ship` button +4. Select `Bobgo` as shipping method +5. Click `Submit Shipment` button diff --git a/uafrica/Customshipping/etc/config.xml b/uafrica/Customshipping/etc/config.xml index c0128631672de6b9479a731981e743b443047f9e..836c795acab083ec4aa8b57835b66f7c4e22907b 100644 --- a/uafrica/Customshipping/etc/config.xml +++ b/uafrica/Customshipping/etc/config.xml @@ -21,7 +21,7 @@ <price>0</price> <model>uafrica\Customshipping\Model\Carrier\Customshipping</model> <name>Fixed</name> - <title>bobGo</title> + <title>uafrica</title> <specificerrmsg>This shipping method is not available. To use this shipping method, please contact us.</specificerrmsg> </uafrica> </carriers> diff --git a/uafrica/Customshipping/etc/module.xml b/uafrica/Customshipping/etc/module.xml index b900003cea8e62d457381312517174ec1e1841b2..8c5f805a7f40344c403f95af89f805806299756f 100644 --- a/uafrica/Customshipping/etc/module.xml +++ b/uafrica/Customshipping/etc/module.xml @@ -9,6 +9,8 @@ <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> <module name="uafrica_Customshipping" setup_version="1.0.0"> <sequence> + <module name="Magento_Webapi"/> + <module name="Magento_Catalog"/> <module name="Magento_Store"/> <module name="Magento_Sales"/> <module name="Magento_Quote"/>