From 8d07c1d2aa970607e22c52c8fd79043cfa3d0a28 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Franc=C3=A9=20Wilke?= <francewilke@gmail.com>
Date: Wed, 14 Aug 2024 17:37:55 +0200
Subject: [PATCH] Change back to latest commit

---
 .DS_Store                                  | Bin 8196 -> 8196 bytes
 Block/System/Config/Form/Field/Version.php |   8 +-
 Helper/Data.php                            |   2 +-
 Model/.DS_Store                            | Bin 0 -> 6148 bytes
 Model/Carrier/AdditionalInfo.php           |  80 +++++++++++
 Model/Carrier/BobGo.php                    | 159 +++++++++++++++++----
 Model/Carrier/Company.php                  |  39 -----
 Model/Carrier/uData.php                    |   6 +-
 Observer/ConfigChangeObserver.php          |  45 ++++++
 Plugin/.DS_Store                           | Bin 0 -> 6148 bytes
 Plugin/Block/.DS_Store                     | Bin 0 -> 6148 bytes
 Readme.md                                  |  30 +---
 composer.json                              |   2 +-
 etc/.DS_Store                              | Bin 0 -> 6148 bytes
 etc/acl.xml                                |  12 ++
 etc/adminhtml/events.xml                   |   7 +
 etc/adminhtml/system.xml                   |  45 ++----
 etc/config.xml                             |   6 +-
 etc/frontend/di.xml                        |   7 +
 etc/module.xml                             |   4 +-
 view/frontend/.DS_Store                    | Bin 0 -> 6148 bytes
 21 files changed, 309 insertions(+), 143 deletions(-)
 create mode 100644 Model/.DS_Store
 create mode 100644 Model/Carrier/AdditionalInfo.php
 delete mode 100644 Model/Carrier/Company.php
 create mode 100644 Observer/ConfigChangeObserver.php
 create mode 100644 Plugin/.DS_Store
 create mode 100644 Plugin/Block/.DS_Store
 create mode 100644 etc/.DS_Store
 create mode 100644 etc/acl.xml
 create mode 100644 etc/adminhtml/events.xml
 create mode 100644 view/frontend/.DS_Store

diff --git a/.DS_Store b/.DS_Store
index f564ed7efa8259ef8da8bd747023d207203cec23..5a522609458bdc7950fbcca5ef75bd1ea890b4c3 100644
GIT binary patch
delta 131
zcmZp1XmQxEL_pS}lYxPOnIV;-gdsUM-^C><CqIdSfq~=bfoW0AlMf0=vO-w*1*91l
zZ2m1^&ZI0T#=yY9#t^`e!%)hQ&XCEFhpchS+*9_2lS75&Ss|=SVMRuR$+Lx}ndHkR
S?+}h+Y?xRmvRPf^E;j&I?I^?m

delta 131
zcmZp1XmQxEL_k)dm4ShQnIV;-gdsUM-^C><CqIdSfq^4pLaR#Y<bwi|tPs|H0cpmD
z&A$cAnUo#n7#JAX7y=k_7)lw^88R92kTv>p{xol#94ai&3Sm_WD>4>Lo-HiRWL`CS
Shj0|*f{BG9o7F|`asvQxwk6O2

diff --git a/Block/System/Config/Form/Field/Version.php b/Block/System/Config/Form/Field/Version.php
index 5d07180..a98a00a 100644
--- a/Block/System/Config/Form/Field/Version.php
+++ b/Block/System/Config/Form/Field/Version.php
@@ -6,13 +6,13 @@ use Magento\Framework\Data\Form\Element\AbstractElement;
 /**
  * Displays Version number in System Configuration
  * @category   BobGroup
- * @package    bobgo_CustomShipping
- * @author     info@bob.co.za
- * @website    https://www.bob.co.za
+ * @package    BobGo
+ * @author     support@bobgo.co.za
+ * @website    https://www.bobgo.co.za
  */
 class Version extends \Magento\Config\Block\System\Config\Form\Field
 {
-    const EXTENSION_URL = 'https://www.bob.co.za';
+    const EXTENSION_URL = 'https://www.bobgo.co.za';
 
     /**
      * @var \BobGroup\BobGo\Helper\Data $helper
diff --git a/Helper/Data.php b/Helper/Data.php
index d0627ee..85a24f2 100644
--- a/Helper/Data.php
+++ b/Helper/Data.php
@@ -8,7 +8,7 @@ use Magento\Store\Model\ScopeInterface;
 
 /**
  * @category   Bob Go
- * @package    bobgo_CustomShipping
+ * @package    BobGo
  * @author     Bob Go
  * @website    https://www.bobgo.co.za
  */
diff --git a/Model/.DS_Store b/Model/.DS_Store
new file mode 100644
index 0000000000000000000000000000000000000000..c57f259eff438387f424e69216bd5d94ea7e1d7f
GIT binary patch
literal 6148
zcmZQzU|@7AO)+F(5MW?n;9!8zOq>i@0Z1N%F(jFwA|Odduo;;QsSHIq>4w3{`B1r0
zYH)`DDDK!9oEZ`siWrI*km4`50OIf&Qy3T+&{X8+ySOCf<R^g=k6#OOQi<6yM{KH6
zh)`9K0ZJ_}+YW#%Wn&0t$Y&^JC}K!vNQI;(m^^1C0|Nt!JhEG6hhKbK25}3T8iY%5
zsX=u|0>~Yscr*k?Ltr!nhHD5gLOjO74WUQL(GVC7fzc3vhXAO2PyqE67#J8FpmYO-
z21zk6GBAL<0E`R_EHF)wegFeV4x|-CgS3KZkX8mp5DRPuSSte~R4XI68v@b?>XLwH
zuyzJUu+1PoSUUqF*k%R>Mu>I>MySn<poT2ST!?lCMu>I>MzHNL*NxJnAut*Oun=H|
zFa$vLzbgX+uKqtn)hIa{0;3@?EJJ{i#U<Fq2~>IF@E)kH1=XjpQ4vrb462S9LG?0J
p53CWu1Q}42fC_`EdyrNT4X%nA85lrXM;ijL02-x7Ltp?x000dJOx6GZ

literal 0
HcmV?d00001

diff --git a/Model/Carrier/AdditionalInfo.php b/Model/Carrier/AdditionalInfo.php
new file mode 100644
index 0000000..0b002a0
--- /dev/null
+++ b/Model/Carrier/AdditionalInfo.php
@@ -0,0 +1,80 @@
+<?php
+
+namespace BobGroup\BobGo\Model\Carrier;
+
+/**
+ * Get the AdditionalInfo information from the request body and return it
+ */
+class AdditionalInfo
+{
+
+    /**
+     * @return mixed|string
+     */
+    public function getDestComp(): mixed
+    {
+        $data = json_decode(file_get_contents('php://input'), true);
+
+        if (isset($data['address']['company'])) {
+            $destComp = $data['address']['company'];
+        } else {
+            $destComp = '';
+        }
+        return $destComp;
+    }
+
+    public function getSuburb(): mixed
+    {
+
+        $data = json_decode(file_get_contents('php://input'), true);
+
+        if (isset($data['address']['custom_attributes'][0]['value'])) {
+            $destSub = $data['address']['custom_attributes'][0]['value'];
+            //print_r($destSub);
+        } else {
+            $destSub = '';
+        }
+        return $destSub;
+    }
+
+    /**
+     * @return mixed|string
+     */
+    public function getDestTelephone(): mixed
+    {
+        $data = json_decode(file_get_contents('php://input'), true);
+
+        if (isset($data['address']['telephone'])) {
+            $destTelephone = $data['address']['telephone'];
+        } else {
+            $destTelephone = '';
+        }
+        return $destTelephone;
+    }
+
+
+    /**
+     * @var \BobGroup\BobGo\Model\Carrier\AdditionalInfo
+     */
+    public $countryFactory;
+
+    public function __construct($countryFactory)
+    {
+        $this->countryFactory = $countryFactory;
+    }
+
+    /**
+     * country full name
+     *
+     * @return string
+     */
+    public function getCountryName($countryId): string
+    {
+        $countryName = '';
+        $country = $this->countryFactory->create()->loadByCode($countryId);
+        if ($country) {
+            $countryName = $country->getName();
+        }
+        return $countryName;
+    }
+}
diff --git a/Model/Carrier/BobGo.php b/Model/Carrier/BobGo.php
index 431e11b..97f5576 100644
--- a/Model/Carrier/BobGo.php
+++ b/Model/Carrier/BobGo.php
@@ -34,7 +34,7 @@ use Psr\Log\LoggerInterface;
 /**
  * Bob Go shipping implementation
  * @category   Bob Go
- * @package    bobgo_CustomShipping
+ * @package    BobGo
  * @author     Bob Go
  * @website    https://www.bobgo.co.za
  * @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
@@ -101,13 +101,18 @@ class BobGo extends AbstractCarrierOnline implements \Magento\Shipping\Model\Car
      */
     protected \Magento\Framework\HTTP\Client\Curl $curl;
 
+    /**
+     * @var ScopeConfigInterface
+     */
+    protected $scopeConfig;  // Declare the scopeConfig property
+
 
     /**
      * @param \Magento\Framework\Controller\Result\JsonFactory $jsonFactory
      */
     protected JsonFactory $jsonFactory;
     private $cartRepository;
-    public Company $company;
+    public AdditionalInfo $additionalInfo;
 
 
     /**
@@ -161,6 +166,7 @@ class BobGo extends AbstractCarrierOnline implements \Magento\Shipping\Model\Car
 
         $this->_storeManager = $storeManager;
         $this->_productCollectionFactory = $productCollectionFactory;
+        $this->scopeConfig = $scopeConfig;
         parent::__construct(
             $scopeConfig,
             $rateErrorFactory,
@@ -181,10 +187,9 @@ class BobGo extends AbstractCarrierOnline implements \Magento\Shipping\Model\Car
         );
         $this->jsonFactory = $jsonFactory;
         $this->curl = $curlFactory->create();
-        $this->company = new Company();
+        $this->additionalInfo = new AdditionalInfo($countryFactory);
     }
 
-
     /*
      * Gets the base url of the store by stripping the http:// or https:// and wwww. from the url
      * leaving just "example.com" since Bob Go API uses this format and not the full url as the Identifier
@@ -294,6 +299,7 @@ class BobGo extends AbstractCarrierOnline implements \Magento\Shipping\Model\Car
         if (!$this->isActive()) {
             return false;
         }
+
         /**
          * Gets the destination company name from Company Name field in the checkout page
          * This method is used is the last resort to get the company name since the company name is not available in _rateFactory
@@ -814,43 +820,61 @@ class BobGo extends AbstractCarrierOnline implements \Magento\Shipping\Model\Car
      */
     protected function _formatRates(mixed $rates, Result $result): void
     {
-        if (empty($rates)) {
+        if (empty($rates['rates'])) {  // Check if the 'rates' key is empty or null
             $error = $this->_rateErrorFactory->create();
             $error->setCarrierTitle($this->getConfigData('title'));
             $error->setErrorMessage($this->getConfigData('specificerrmsg'));
 
             $result->append($error);
         } else {
-            foreach ($rates['rates'] as $title) {
+
+            foreach ($rates['rates'] as $rate) {
 
                 $method = $this->_rateMethodFactory->create();
-                if (isset($title)){
+
+                if (isset($rate)) {
+                    // Set the carrier code
                     $method->setCarrier(self::CODE);
 
+                    // Strip out the redundant 'bobgo_' prefix if present
+                    $serviceCode = $rate['service_code'];
+                    if (strpos($serviceCode, 'bobgo_') === 0) {
+                        $serviceCode = substr($serviceCode, strlen('bobgo_'));
+                    }
+
+                    // Set the method with the modified service code
+                    $method->setMethod($serviceCode);
 
+                    // Set additional info if required
                     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']);
+                        $min_delivery_date = isset($rate['min_delivery_date']) && $rate['min_delivery_date'] !== null
+                            ? $this->getWorkingDays(date('Y-m-d'), $rate['min_delivery_date'])
+                            : null;
 
-                        $this->deliveryDays($min_delivery_date, $max_delivery_date, $method);
+                        $max_delivery_date = isset($rate['max_delivery_date']) && $rate['max_delivery_date'] !== null
+                            ? $this->getWorkingDays(date('Y-m-d'), $rate['max_delivery_date'])
+                            : null;
 
-                    } else {
-                        $method->setCarrierTitle($this->getConfigData('title'));
+                        $this->deliveryDays($min_delivery_date, $max_delivery_date, $method);
                     }
 
-                }
+                    // Set the method title, price, and cost
+//                    $description = $rate['description'];
+                    $service_name = $rate['service_name'];
+//                    $method->setMethodTitle("$service_name | $description" );
+                    $method->setMethodTitle("$service_name");
+                    $price = $rate['total_price'];
+                    $cost = $rate['total_price'];
 
-                $method->setMethod($title['service_code']);
-                $method->setMethodTitle($title['service_name']);
-                $method->setPrice($title['total_price'] / self::UNITS);
-                $method->setCost($title['total_price'] / self::UNITS);
+                    $method->setPrice($price);
+                    $method->setCost($cost);
 
-                $result->append($method);
+                    $result->append($method);
+                }
             }
         }
     }
 
-
     /**
      * Prepare received checkpoints and activity from Bob Go Shipment Tracking API
      * @param $response
@@ -865,7 +889,7 @@ class BobGo extends AbstractCarrierOnline implements \Magento\Shipping\Model\Car
                 'activity' => $checkpoint['status'],
                 'deliverydate' => $this->formatDate($checkpoint['time']),
                 'deliverytime' => $this->formatTime($checkpoint['time']),
-              //  'deliverylocation' => 'Unavailable',//TODO: remove this line
+                //  'deliverylocation' => 'Unavailable',//TODO: remove this line
             ];
         }
         return $result;
@@ -956,31 +980,37 @@ class BobGo extends AbstractCarrierOnline implements \Magento\Shipping\Model\Car
      * @param $method
      * @return void
      */
-    protected function deliveryDays(int $min_delivery_date, int $max_delivery_date, $method): void
+    protected function deliveryDays(?int $min_delivery_date, ?int $max_delivery_date, $method): void
     {
+        if ($min_delivery_date === null || $max_delivery_date === null) {
+            return;
+        }
+
         if ($min_delivery_date !== $max_delivery_date) {
-            $method->setCarrierTitle('delivery in '.$min_delivery_date . ' - ' . $max_delivery_date . ' days');
-        }else{
-            $method->setCarrierTitle('delivery in ' . $min_delivery_date . ' days');
+            $method->setCarrierTitle('Delivery in '.$min_delivery_date . ' - ' . $max_delivery_date . ' days');
+        } else {
             if ($min_delivery_date && $max_delivery_date == 1) {
-                $method->setCarrierTitle('delivery in '.$min_delivery_date . ' day');
+                $method->setCarrierTitle('Delivery in '.$min_delivery_date . ' day');
+            } else {
+                $method->setCarrierTitle('Delivery in ' . $min_delivery_date . ' days');
             }
         }
     }
 
+
     /**
      * @return mixed|string
      */
     public function getDestComp(): mixed
     {
-        return $this->company->getDestComp();
+        return $this->additionalInfo->getDestComp();
     }
     /**
      * @return mixed|string
      */
     public function getDestSuburb(): mixed
     {
-        return $this->company->getSuburb();
+        return $this->additionalInfo->getSuburb();
     }
 
     /**
@@ -1040,4 +1070,79 @@ class BobGo extends AbstractCarrierOnline implements \Magento\Shipping\Model\Car
         }
         return true;
     }
+
+    public function triggerRatesTest()
+    {
+        // Check if the 'Show rates for checkout' setting is enabled
+        $isEnabled = $this->scopeConfig->getValue('carriers/bobgo/active', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);
+
+        if ($isEnabled) {
+            // Sample test payload, replace with actual structure
+            $payload = [
+                'identifier' => $this->getBaseUrl(),
+                'rate' => [
+                    'origin' => [
+                        'company' => 'Test Store',
+                        'address1' => '123 Test St',
+                        'address2' => '',
+                        'city' => 'Test City',
+                        'suburb' => 'Test Suburb',
+                        'province' => 'Test Province',
+                        'country_code' => 'ZA',
+                        'postal_code' => '2000',
+                    ],
+                    'destination' => [
+                        'company' => 'Test Company',
+                        'address1' => '456 Test Ave',
+                        'address2' => '',
+                        'suburb' => 'Test Suburb',
+                        'city' => 'Test City',
+                        'province' => 'Test Province',
+                        'country_code' => 'ZA',
+                        'postal_code' => '3000',
+                    ],
+                    'items' => [
+                        [
+                            'sku' => 'test-sku-1',
+                            'quantity' => 1,
+                            'price' => 100.00,
+                            'weight' => 500, // in grams
+                        ]
+                    ],
+                ]
+            ];
+
+            try {
+                // Perform the API request
+                $this->curl->addHeader('Content-Type', 'application/json');
+                $this->curl->post($this->getApiUrl(), json_encode($payload));
+                $statusCode = $this->curl->getStatus();
+                $responseBody = $this->curl->getBody();
+
+                // Decode the response
+                $response = json_decode($responseBody, true);
+
+                // Check if the response contains a 'message' (indicating an error)
+                if (isset($response['message'])) {
+                    throw new \Exception('Error from BobGo: ' . $response['message']);
+                }
+
+                // Check if the response contains rates with a valid id field
+                if (isset($response['rates']) && is_array($response['rates']) && !empty($response['rates'])) {
+                    foreach ($response['rates'] as $rate) {
+                        if (isset($rate['id']) && $rate['id'] !== null) {
+                            return $response; // Successful response with a valid id
+                        }
+                    }
+                    throw new \Exception('Rates received but id field is empty or invalid.');
+                } else {
+                    throw new \Exception('Received response but no valid rates were found.');
+                }
+            } catch (\Exception $e) {
+                return false;
+            }
+        }
+        return false;
+    }
+
 }
diff --git a/Model/Carrier/Company.php b/Model/Carrier/Company.php
deleted file mode 100644
index b554759..0000000
--- a/Model/Carrier/Company.php
+++ /dev/null
@@ -1,39 +0,0 @@
-<?php
-
-namespace BobGroup\BobGo\Model\Carrier;
-
-/**
- * Get the Company information from the request body and return it
- */
-class Company
-{
-
-    /**
-     * @return mixed|string
-     */
-    public function getDestComp(): mixed
-    {
-        $data = json_decode(file_get_contents('php://input'), true);
-
-        if (isset($data['address']['company'])) {
-            $destComp = $data['address']['company'];
-        } else {
-            $destComp = '';
-        }
-        return $destComp;
-    }
-
-    public function getSuburb(): mixed
-    {
-
-        $data = json_decode(file_get_contents('php://input'), true);
-
-        if (isset($data['address']['custom_attributes'][0]['value'])) {
-            $destSub = $data['address']['custom_attributes'][0]['value'];
-            //print_r($destSub);
-        } else {
-            $destSub = '';
-        }
-        return $destSub;
-    }
-}
diff --git a/Model/Carrier/uData.php b/Model/Carrier/uData.php
index 4ccffa2..df3a168 100644
--- a/Model/Carrier/uData.php
+++ b/Model/Carrier/uData.php
@@ -10,11 +10,7 @@ class uData
 {
 
     /** Tracking Endpoint */
-    //dev
-    public const TRACKING = 'https://api.dev.bobgo.co.za/tracking?channel=localhost&tracking_reference=';
-
-    //production
-    //public const TRACKING = 'https://api.dev.bobgo.co.za/tracking?channel=%s&tracking_reference=%s';
+    public const TRACKING = 'https://api.dev.bobgo.co.za/tracking?channel=%s&tracking_reference=%s';
 
     /*** RATES API Endpoint*/
     public const RATES_ENDPOINT = 'https://api.dev.bobgo.co.za/rates-at-checkout/magento';
diff --git a/Observer/ConfigChangeObserver.php b/Observer/ConfigChangeObserver.php
new file mode 100644
index 0000000..e3dad60
--- /dev/null
+++ b/Observer/ConfigChangeObserver.php
@@ -0,0 +1,45 @@
+<?php
+
+namespace BobGroup\BobGo\Observer;
+
+use Magento\Framework\Event\Observer;
+use Magento\Framework\Event\ObserverInterface;
+use Magento\Framework\Message\ManagerInterface;
+use Psr\Log\LoggerInterface;
+use BobGroup\BobGo\Model\Carrier\BobGo;
+
+class ConfigChangeObserver implements ObserverInterface
+{
+    protected $bobGo;
+    protected $logger;
+    protected $messageManager;
+
+    public function __construct(
+        BobGo $bobGo,
+        LoggerInterface $logger,
+        ManagerInterface $messageManager
+    ) {
+        $this->bobGo = $bobGo;
+        $this->logger = $logger;
+        $this->messageManager = $messageManager;
+    }
+
+    public function execute(Observer $observer)
+    {
+        $changedPaths = $observer->getEvent()->getData('changed_paths');
+
+        if (is_array($changedPaths) && in_array('carriers/bobgo/active', $changedPaths)) {
+
+            if ($this->bobGo->isActive()) {
+                $result = $this->bobGo->triggerRatesTest();
+
+                if ($result !== false) {
+                    $this->messageManager->addSuccessMessage(__('Bob Go rates at checkout test is successful.'));
+                } else {
+                    $this->messageManager->addErrorMessage(__('Bob Go rates at checkout test failed. Please visit https://www.bobgo.co.za/ and enable this channel for rates at checkout.'));
+                }
+            }
+        }
+    }
+
+}
diff --git a/Plugin/.DS_Store b/Plugin/.DS_Store
new file mode 100644
index 0000000000000000000000000000000000000000..689f74aebb9f0ea93d13c40a72825a9e06df27b5
GIT binary patch
literal 6148
zcmZQzU|@7AO)+F(5MW?n;9!8zOq>i@0Z1N%F(jFwA|Odduo>Ao>4w3{`MCv9nNe!6
zhX5$<SQ(rcav1U%k{QtAk7F(a0|Sz5ZoZ34QcivnDACBzJY`>KcFYl7MG65G1sTXG
zL;(~&91PA384Rf)`x){XN*PK}QxQic$Uby6$ZmN#5AGHWvvTthF2bh{)m@-`0dm?X
z9u0xf5Eu=CVHpC95MOa{L+DX*Gz3ONU^E2aApj~LKn*ky?EvaCFfcGQKxmK<10w?i
zxC_9@z`z321nCDbfaE}0K{QA!hz4n8U<9$iW`MOaFhaF5g1aFgeUPRXBLi4F10w@i
zI|C!wW(EdEu+0n%j1cV%j8K~yK@C}uxe)CPj1cV%j1cWG=Z(^%Aut*O&=6pT&;p?P
z-<5#@SN|WPYLpxefzc2cmLb5%;u7rQ1gbo7cn?(9g6h)*s640+2G!<_p!ymi2Cj;k
jAOngLP+?GY57G*v!BsIMqzy6J5P${HC_Nei0}uiL7Zgj%

literal 0
HcmV?d00001

diff --git a/Plugin/Block/.DS_Store b/Plugin/Block/.DS_Store
new file mode 100644
index 0000000000000000000000000000000000000000..17a3f4bbd7cabc8ac14985439ccbfd116d21bb32
GIT binary patch
literal 6148
zcmZQzU|@7AO)+F(5MW?n;9!8zOq>i@0Z1N%F(jFwA|Odduo(diMGW~2Wek}NDNwml
zYH)`DDDHR}To@7=N*EFukmE0vp@^Y4C*3eOIX|}m;tA$b1_lN^s&n&QT#|C~lR$|o
zf66KQLbGFzgmk2ksG}eQ*+roA%fP`9!cfGJ$dJsC&5+5E$B>TdYE})9d(hP&yY<>E
zxLYyI%FRc(5T80M?t%o`C^;GeqaiRF0)sCE7$HvL;D*qn<Y)+thQMeDz(W93J}7|t
z3JeSk4p6!QLW86j7#SGAT>wS~1{RnmNI!r9BnQ$8qCr|gG)OB0BZvhy1FV&S5vr9D
z+zkQg12^dy7#YCY85qGfgT%qw85qGfGcYhhv@<Y5ZDs^DWI^Uav@<Y5v@<Y*ZHKvT
zlpYO%(GY-z05gOk0IL6885nT&{~@YI$<YuP4S``90*ov!!7fgq$`gn8Ky@vsK23ni
zgX&;Vb<7B=ml0y%s+b8fpeO+q237YUtsoj)6*Dq0fV7S_1YiL)N{@!X0E7Sl9otvz

literal 0
HcmV?d00001

diff --git a/Readme.md b/Readme.md
index 1757dd1..7d69166 100644
--- a/Readme.md
+++ b/Readme.md
@@ -1,29 +1,3 @@
-# Installing Magento locally 
-
-**Note:** For more information, visit https://github.com/markshust/docker-magento
-
-1. Make sure you have `composer` installed globally and a GitHub personal access token configured using `composer global config github-oauth.github.com <YOUR_PERSONAL_ACCESS_TOKEN>`
-2. Create a new folder, ie: `Documents/Magento`
-3. `cd` into the folder 
-4. Run command `curl -s https://raw.githubusercontent.com/markshust/docker-magento/master/lib/onelinesetup | bash -s -- bobgomagento.test 2.4.4-p1 community`
-5. When asked for the username and password, provide the Abobe public and private key: 
-
-- Public key: `98b4828a495e7e0e13d80d8bf94f3b1c`
-- Private key: `082ced46919bffe1b6db0f96de96d608`
-
-Once configured, do the following to create an admin user (and make life easier for yourself):
-
-- Create Admin User: `bin/magento admin:user:create`
-- Disable 2FA: `bin/magento module:disable Magento_TwoFactorAuth`
-- Disable Admin Captcha: `bin/magento config:set admin/captcha/enable 0`
-
-
-### Adobe account details
-
-- Email: `tech@uafrica.com`
-- Password: `mR3mdr0311@P`
-
-
 # Magento 2 Bob Go Shipping Extension
 
 ## Introduction
@@ -41,13 +15,12 @@ A complete guide to install Magento Bob Go Shipping extension in Magento 2.
 
 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 BobGroup/BobGo
+composer require bob-public-utils/bobgo-magento-extension
 ```
 #### 2. Enter following commands to enable the module:
 
@@ -60,7 +33,6 @@ bin/magento setup:di:compile
 bin/magento setup:static-content:deploy
 ```
 
-
 ### Option 2: Install via zip file
 
 1. Download the extension zip file from the link below: </br>
diff --git a/composer.json b/composer.json
index 76742bd..b7c15e0 100644
--- a/composer.json
+++ b/composer.json
@@ -11,7 +11,7 @@
     }
   ],
   "license": [
-   "AFL-3.0",
+    "AFL-3.0",
     "OSL-3.0"
   ],
   "autoload": {
diff --git a/etc/.DS_Store b/etc/.DS_Store
new file mode 100644
index 0000000000000000000000000000000000000000..a959c9c8a835e4f3e5b3131f6477abb5843156c1
GIT binary patch
literal 6148
zcmZQzU|@7AO)+F(5MW?n;9!8zOq>i@0Z1N%F(jFwA|Odduo-y_84M*1xePfu=}@^*
zYH)`DDDF5J5*bn$av3rikmAoUI5|JJ0OEL&I0gm=EUI$zU0jlK@{>S`$Z6Lp`$Ds0
zj<{5&5UH{t1KDN+kOMdv(in;u@)`0NN*GcZ@)%Nb(vj6L9|qZvt_Im{*2m#)!!Rp1
zAK@~5>QLPU$~PdVjpES|7!85Z5EzmnzzA_Q2RDQsB}YSGGz3ON03HIM@<9RAS72aZ
zaDdVc5E>-Kz{tP=?gB6}FtEThLHYp<AUTj$5Dn4_qCr|27(pzs8DOmpj8LtN;BE*=
zAEar;$N<*PzzDV(Bo5ZjzzDXPfq@aCoq-W*Gb5-W3o;j?oq-Xeoq-W-JIr;X^k@i-
zh5#%Cm>~=SQ2p=9z<{g&4^cHrj)uT!2n@>*U}SL#c5wn#o;bV*s%t^@X#!LpR0o5q
uV@6QDj1U7?#Y~U^MG2@dsJaJf1<~NDn2~`2q;<3*01Kc|dNc$EAOrwBi&FCd

literal 0
HcmV?d00001

diff --git a/etc/acl.xml b/etc/acl.xml
new file mode 100644
index 0000000..4abc946
--- /dev/null
+++ b/etc/acl.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0"?>
+<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:noNamespaceSchemaLocation="urn:magento:framework:Acl/etc/acl.xsd">
+    <acl>
+        <resources>
+            <!-- Define at least one minimal resource -->
+            <resource id="Magento_Backend::admin">
+                <!-- You can leave this empty if you don't want to define specific permissions -->
+            </resource>
+        </resources>
+    </acl>
+</config>
diff --git a/etc/adminhtml/events.xml b/etc/adminhtml/events.xml
new file mode 100644
index 0000000..1fac000
--- /dev/null
+++ b/etc/adminhtml/events.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0"?>
+<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
+    <event name="admin_system_config_changed_section_carriers">
+        <observer name="bobgo_config_change_observer" instance="BobGroup\BobGo\Observer\ConfigChangeObserver" />
+    </event>
+
+</config>
diff --git a/etc/adminhtml/system.xml b/etc/adminhtml/system.xml
index 0d3fa3a..29ad3d7 100644
--- a/etc/adminhtml/system.xml
+++ b/etc/adminhtml/system.xml
@@ -2,22 +2,6 @@
 <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
     <system>
 
-        <tab id="bobgo" translate="label" sortOrder="2">
-            <label>Bob Go</label>
-        </tab>
-        <section id="BobGroup_BobGo"  showInDefault="1">
-            <tab>bobgo</tab>
-            <label>Settings</label>
-            <resource>Magento_Config::config</resource>
-            <group id="general"  showInDefault="1">
-                <label>Settings</label>
-                <field id="enabled" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
-                    <label>Extension enabled</label>
-                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
-                </field>
-            </group>
-        </section>
-
         <section id="general" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
             <group id="store_information" translate="label" type="text" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1">
                 <field id="suburb" translate="label" type="text" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="0">
@@ -39,41 +23,40 @@
                     <comment>When this setting is enabled, your customers will be presented with shipping rates at checkout, as configured on the Bob Go platform under Rates at checkout.</comment>
                     <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                 </field>
-                <field id="specificerrmsg" translate="label" type="textarea" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="1">
-                    <label>Displayed Error Message</label>
-                    <comment>The message displayed to the customer when no rates were available on Bob Go.</comment>
+                <field id="additional_info" translate="label" type="select" sortOrder="7" showInDefault="1" showInWebsite="1">
+                    <label>Show additional rate information</label>
+                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
+                    <comment>Displays the delivery timeframe and additional service level description as configured on Bob Go.</comment>
                 </field>
 
-                <field id="sallowspecific" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0">
+                <!--                Hiding these fields (specificerrmsg, sallowspecific, specificcountry, showmethod, unit_of_measure, max_package_weight) from the admin protal-->
+                <field id="specificerrmsg" translate="label" type="textarea" sortOrder="80" showInDefault="0" showInWebsite="0" showInStore="0">
+                    <label>Displayed Error Message</label>
+                    <comment>We could not find any shipping rates for your delivery address. Please make sure your address is correct. If you are experiencing problems, please contact BobGo (support@bobgo.co.za).</comment>
+                </field>
+                <field id="sallowspecific" translate="label" type="select" sortOrder="90" showInDefault="0" showInWebsite="0" showInStore="0">
                     <label>Ship to Applicable Countries</label>
                     <frontend_class>shipping-applicable-country</frontend_class>
                     <source_model>Magento\Shipping\Model\Config\Source\Allspecificcountries</source_model>
                 </field>
-
-                <field id="specificcountry" translate="label" type="multiselect" sortOrder="91" showInDefault="1" showInWebsite="1" showInStore="0">
+                <field id="specificcountry" translate="label" type="multiselect" sortOrder="91" showInDefault="0" showInWebsite="0" showInStore="0">
                     <label>Ship to Specific Countries</label>
                     <source_model>Magento\Directory\Model\Config\Source\Country</source_model>
                     <can_be_empty>1</can_be_empty>
                 </field>
-
-                <field id="showmethod" translate="label" type="select" sortOrder="92" showInDefault="1" showInWebsite="1" showInStore="0">
+                <field id="showmethod" translate="label" type="select" sortOrder="92" showInDefault="0" showInWebsite="0" showInStore="0">
                     <label>Show Method if Not Applicable</label>
                     <frontend_class>shipping-skip-hide</frontend_class>
                     <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
                 </field>
-                <field id="unit_of_measure" translate="label" type="select" sortOrder="73" showInDefault="1" showInWebsite="1">
+                <field id="unit_of_measure" translate="label" type="select" sortOrder="73" showInDefault="0" showInWebsite="0">
                     <label>Weight Unit</label>
                     <source_model>BobGroup\BobGo\Model\Source\Unitofmeasure</source_model>
                 </field>
-                <field id="max_package_weight" translate="label" type="text" sortOrder="90" showInDefault="1" showInWebsite="1">
+                <field id="max_package_weight" translate="label" type="text" sortOrder="90" showInDefault="0" showInWebsite="0">
                     <label>Maximum Package Weight (Please consult your shipping carrier for maximum supported shipping weight)</label>
                     <validate>validate-number validate-zero-or-greater</validate>
                 </field>
-                <field id="additional_info" translate="label" type="select" sortOrder="7" showInDefault="1" showInWebsite="1">
-                    <label>Show additional rate information</label>
-                    <source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
-                    <comment>Displays the delivery timeframe and additional service level description as configured on Bob Go.</comment>
-                </field>
             </group>
         </section>
 
diff --git a/etc/config.xml b/etc/config.xml
index eb34051..9e4c986 100644
--- a/etc/config.xml
+++ b/etc/config.xml
@@ -9,15 +9,11 @@
 
         <carriers>
             <bobgo>
-                <active>0</active>
-<!--                <sallowspecific>1</sallowspecific>
-                <specificcountry>ZA</specificcountry>-->
+                <active>1</active>
                 <price>0.00</price>
                 <model>BobGroup\BobGo\Model\Carrier\BobGo</model>
                 <name>Fixed</name>
-                <max_package_weight>300</max_package_weight>
                 <title>Bob Go</title>
-                <specificerrmsg>We could not find any shipping rates for your delivery address. Please make sure your address is correct. If you are experiencing problems, please contact us.</specificerrmsg>
             </bobgo>
         </carriers>
 
diff --git a/etc/frontend/di.xml b/etc/frontend/di.xml
index 2ee6f54..f424156 100644
--- a/etc/frontend/di.xml
+++ b/etc/frontend/di.xml
@@ -7,4 +7,11 @@
             </argument>
         </arguments>
     </type>
+    <type name="BobGroup\BobGo\Observer\ConfigChangeObserver">
+        <arguments>
+            <argument name="scopeConfig" xsi:type="object">Magento\Framework\App\Config\ScopeConfigInterface</argument>
+            <argument name="logger" xsi:type="object">Psr\Log\LoggerInterface</argument>
+        </arguments>
+    </type>
+
 </config>
diff --git a/etc/module.xml b/etc/module.xml
index d736136..fe2b36d 100644
--- a/etc/module.xml
+++ b/etc/module.xml
@@ -2,7 +2,7 @@
 <!--
 /**
  * @category   Bob Go
- * @package    bobgo_CustomShipping
+ * @package    BobGo
  * @author     Bob Go
  */
 -->
@@ -15,6 +15,8 @@
             <module name="Magento_Sales"/>
             <module name="Magento_Quote"/>
             <module name="Magento_SalesRule"/>
+            <module name="Magento_Config"/>
+            <module name="Magento_Shipping"/>
         </sequence>
     </module>
 </config>
diff --git a/view/frontend/.DS_Store b/view/frontend/.DS_Store
new file mode 100644
index 0000000000000000000000000000000000000000..073d5f170af0ac13acc7ea6f79c8547b36d9f88d
GIT binary patch
literal 6148
zcmZQzU|@7AO)+F(5MW?n;9!8zj35RBCIAV8Fop~hR0Jf+2sWdXp(H2WFgQ6sw*V?P
z*eQ_P*%)#d5*aEP@)<DP&)depz<?s3oA2V1l#`zX3b-9lPuUlm9dpD~lR{8UK?ZU-
zDS*O>nW3B^l_3c=1O>Vo7#N^3$aV+4f!ht2Mc9fdi)vp0$i7iL8UmvsFd71*AuuvS
zfDz(t4sHlNN{)uWXb6mk06YXh<pZc;3ZflAeFg>wh6V@?5@KLvU;uXk7#SE?V45KP
z00xj8NGpg2X$8?BtqhDH7T651Rt83>Rz`3)1f&ntB>~Z3?F@_zVC@WyV4E2j7{N9(
zFfc;2GcZDJhIL*TA=()jA=()jA=+Wi8>L4>U^E1vA;1iw1wi$`D+2>83qeFj$<YuP
z4S^960*ov!!7fhVN*TL<L3J&tK23m1gX&;#Z4S``k_J`l;HsDjGN32{RSFUZX$8^X
Ws+bYdh8S%KzyfHL9u0v32mt^M7D%B0

literal 0
HcmV?d00001

-- 
GitLab