diff --git a/Helper/Data.php b/Helper/Data.php index d0627eefd27a235e7b0b5b498f8e22ab4fd1a215..e502d61b28c4395bd907f2c88b17e4d3e93a0aa7 100644 --- a/Helper/Data.php +++ b/Helper/Data.php @@ -1,88 +1,88 @@ <?php -namespace BobGroup\BobGo\Helper; - -use Magento\Framework\App\Helper\AbstractHelper; -use Magento\Framework\App\Helper\Context; -use Magento\Framework\Module\ModuleListInterface; -use Magento\Store\Model\ScopeInterface; - -/** - * @category Bob Go - * @package bobgo_CustomShipping - * @author Bob Go - * @website https://www.bobgo.co.za - */ -class Data extends AbstractHelper -{ - - const XML_PATH_ENABLED = 'BobGroup_BobGo/general/enabled'; - const XML_PATH_DEBUG = 'BobGroup_BobGo/general/debug'; - - /** - * @var \Psr\Log\LoggerInterface - */ - protected $_logger; - - /** - * @var ModuleListInterface - */ - protected $_moduleList; - - /** - * @param Context $context - * @param ModuleListInterface $moduleList - */ - public function __construct( - Context $context, - ModuleListInterface $moduleList - ) { - $this->_logger = $context->getLogger(); - $this->_moduleList = $moduleList; - - parent::__construct($context); - } - - /** - * Check if enabled - * - * @return string|null - */ - public function isEnabled() - { - return $this->scopeConfig->getValue( - self::XML_PATH_ENABLED, - ScopeInterface::SCOPE_STORE - ); - } - - public function getDebugStatus() - { - return $this->scopeConfig->getValue( - self::XML_PATH_DEBUG, - ScopeInterface::SCOPE_STORE - ); - } - - public function getExtensionVersion() - { - $moduleCode = 'BobGroup_BobGo'; - $moduleInfo = $this->_moduleList->getOne($moduleCode); - return $moduleInfo['setup_version']; - } - - /** - * - * @param $message - * @param bool|false $useSeparator - */ - public function log($message, $useSeparator = false) - { - if ($this->getDebugStatus()) { - if ($useSeparator) { - $this->_logger->addDebug(str_repeat('=', 100)); - } - - $this->_logger->addDebug($message); - } - } -} +//namespace BobGroup\BobGo\Helper; +// +//use Magento\Framework\App\Helper\AbstractHelper; +//use Magento\Framework\App\Helper\Context; +//use Magento\Framework\Module\ModuleListInterface; +//use Magento\Store\Model\ScopeInterface; +// +///** +// * @category Bob Go +// * @package bobgo_CustomShipping +// * @author Bob Go +// * @website https://www.bobgo.co.za +// */ +//class Data extends AbstractHelper +//{ +// +// const XML_PATH_ENABLED = 'BobGroup_BobGo/general/enabled'; +// const XML_PATH_DEBUG = 'BobGroup_BobGo/general/debug'; +// +// /** +// * @var \Psr\Log\LoggerInterface +// */ +// protected $_logger; +// +// /** +// * @var ModuleListInterface +// */ +// protected $_moduleList; +// +// /** +// * @param Context $context +// * @param ModuleListInterface $moduleList +// */ +// public function __construct( +// Context $context, +// ModuleListInterface $moduleList +// ) { +// $this->_logger = $context->getLogger(); +// $this->_moduleList = $moduleList; +// +// parent::__construct($context); +// } +// +// /** +// * Check if enabled +// * +// * @return string|null +// */ +// public function isEnabled() +// { +// return $this->scopeConfig->getValue( +// self::XML_PATH_ENABLED, +// ScopeInterface::SCOPE_STORE +// ); +// } +// +// public function getDebugStatus() +// { +// return $this->scopeConfig->getValue( +// self::XML_PATH_DEBUG, +// ScopeInterface::SCOPE_STORE +// ); +// } +// +// public function getExtensionVersion() +// { +// $moduleCode = 'BobGroup_BobGo'; +// $moduleInfo = $this->_moduleList->getOne($moduleCode); +// return $moduleInfo['setup_version']; +// } +// +// /** +// * +// * @param $message +// * @param bool|false $useSeparator +// */ +// public function log($message, $useSeparator = false) +// { +// if ($this->getDebugStatus()) { +// if ($useSeparator) { +// $this->_logger->addDebug(str_repeat('=', 100)); +// } +// +// $this->_logger->addDebug($message); +// } +// } +//} diff --git a/Logger/Handler.php b/Logger/Handler.php index c5c15fe182ace7aac80573f122097e99e4a94fba..22703cb87bd424fb05dbfb6fdbfac58187146b53 100644 --- a/Logger/Handler.php +++ b/Logger/Handler.php @@ -1,12 +1,12 @@ <?php - -namespace BobGroup\BobGo\Logger; - -use Monolog\Logger; -use Magento\Framework\Logger\Handler\Base as MagentoBaseHandler; - -class Handler extends MagentoBaseHandler -{ - protected $fileName = '/var/log/bobgo_plugin.log'; - protected $loggerType = Logger::DEBUG; -} +// +//namespace BobGroup\BobGo\Logger; +// +//use Monolog\Logger; +//use Magento\Framework\Logger\Handler\Base as MagentoBaseHandler; +// +//class Handler extends MagentoBaseHandler +//{ +// protected $fileName = '/var/log/bobgo_plugin.log'; +// protected $loggerType = Logger::DEBUG; +//} diff --git a/Model/Carrier/BobGo.php b/Model/Carrier/BobGo.php index 8f2b789cf2cafce0f6abc9a872d445e34c2c22fd..d54a1f278b95a7be24dc0cec3f30c386786da96a 100644 --- a/Model/Carrier/BobGo.php +++ b/Model/Carrier/BobGo.php @@ -1179,140 +1179,207 @@ //} +//namespace BobGroup\BobGo\Model\Carrier; +// +//use Magento\Framework\App\Config\ScopeConfigInterface; +//use Magento\Framework\HTTP\ZendClientFactory; +//use Magento\Quote\Model\Quote\Address\RateRequest; +//use Magento\Shipping\Model\Carrier\AbstractCarrierOnline; +//use Magento\Shipping\Model\Carrier\CarrierInterface; +//use Magento\Shipping\Model\Rate\Result; +//use BobGroup\BobGo\Logger\Logger; +// +//class BobGo extends AbstractCarrierOnline implements CarrierInterface +//{ +// protected $_code = 'bobgo'; +// protected $_isFixed = true; +// +// protected $scopeConfig; +// protected $httpClientFactory; +// protected $logger; +// +// public function __construct( +// ScopeConfigInterface $scopeConfig, +// \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory, +// Logger $logger, +// ZendClientFactory $httpClientFactory, +// array $data = [] +// ) { +// $this->scopeConfig = $scopeConfig; +// $this->httpClientFactory = $httpClientFactory; +// $this->logger = $logger; +// parent::__construct($scopeConfig, $rateErrorFactory, $logger, $data); +// } +// +// public function collectRates(RateRequest $request) +// { +// $this->logger->info('BobGo collectRates method called'); +// +// if (!$this->getConfigFlag('active')) { +// $this->logger->info('BobGo is not active'); +// return false; +// } +// +// $this->logger->info('BobGo is active, proceeding with rate collection'); +// +// $result = $this->_rateFactory->create(); +// +// // Prepare request data for API call +// $params = [ +// 'dest_country_id' => $request->getDestCountryId(), +// 'dest_region_id' => $request->getDestRegionId(), +// 'dest_postcode' => $request->getDestPostcode(), +// 'package_weight' => $request->getPackageWeight(), +// 'package_value' => $request->getPackageValue(), +// 'package_qty' => $request->getPackageQty(), +// ]; +// +// $this->logger->info('Request parameters: ' . json_encode($params)); +// +// try { +// $apiResponse = $this->_fetchRatesFromApi($params); +// $this->logger->info('API response: ' . json_encode($apiResponse)); +// +// if ($apiResponse && isset($apiResponse['rates']) && !empty($apiResponse['rates'])) { +// foreach ($apiResponse['rates'] as $rateData) { +// $rate = $this->_rateMethodFactory->create(); +// $rate->setCarrier($this->_code); +// $rate->setCarrierTitle($this->getConfigData('title')); +// $rate->setMethod($rateData['method']); +// $rate->setMethodTitle($rateData['method_title']); +// $rate->setPrice($rateData['price']); +// $rate->setCost($rateData['cost']); +// $result->append($rate); +// } +// } else { +// $this->logger->info('No rates returned from API'); +// $error = $this->_rateErrorFactory->create(); +// $error->setCarrier($this->_code); +// $error->setCarrierTitle($this->getConfigData('title')); +// $error->setErrorMessage($this->getConfigData('specificerrmsg')); +// return $error; +// } +// } catch (\Exception $e) { +// $this->logger->error('Error fetching rates from API: ' . $e->getMessage()); +// $error = $this->_rateErrorFactory->create(); +// $error->setCarrier($this->_code); +// $error->setCarrierTitle($this->getConfigData('title')); +// $error->setErrorMessage($this->getConfigData('specificerrmsg')); +// return $error; +// } +// +// return $result; +// } +// +// protected function _fetchRatesFromApi($params) +// { +// $url = 'https://api.dev.bobgo.co.za/rates-at-checkout/magento'; +// $client = $this->httpClientFactory->create(); +// $client->setUri($url); +// $client->setConfig(['timeout' => 30]); +// $client->setHeaders(['Content-Type' => 'application/json']); +// $client->setMethod(\Zend_Http_Client::POST); +// $client->setRawData(json_encode($params), 'application/json'); +// +// try { +// $response = $client->request(); +// $responseBody = $response->getBody(); +// +// // Log the response body +// $this->logger->info('Response body: ' . var_export($responseBody, true)); +// +// if ($responseBody === null) { +// $this->logger->error('API response body is null'); +// return false; +// } +// +// if ($response->isSuccessful()) { +// return json_decode($responseBody, true); +// } else { +// $this->logger->error('API request failed with status: ' . $response->getStatus()); +// } +// } catch (\Exception $e) { +// $this->logger->error('Exception during API request: ' . $e->getMessage()); +// } +// +// return false; +// } +// +// public function getAllowedMethods() +// { +// return [$this->_code => $this->getConfigData('name')]; +// } +// +//} + + +declare(strict_types=1); + namespace BobGroup\BobGo\Model\Carrier; use Magento\Framework\App\Config\ScopeConfigInterface; -use Magento\Framework\HTTP\ZendClientFactory; use Magento\Quote\Model\Quote\Address\RateRequest; -use Magento\Shipping\Model\Carrier\AbstractCarrierOnline; +use Magento\Quote\Model\Quote\Address\RateResult\Method; +use Magento\Quote\Model\Quote\Address\RateResult\MethodFactory; +use Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory; +use Magento\Shipping\Model\Carrier\AbstractCarrier; use Magento\Shipping\Model\Carrier\CarrierInterface; use Magento\Shipping\Model\Rate\Result; -use BobGroup\BobGo\Logger\Logger; +use Magento\Shipping\Model\Rate\ResultFactory; +use Psr\Log\LoggerInterface; -class BobGo extends AbstractCarrierOnline implements CarrierInterface +class BobGo extends AbstractCarrier implements CarrierInterface { - protected $_code = 'bobgo'; - protected $_isFixed = true; - - protected $scopeConfig; - protected $httpClientFactory; - protected $logger; + protected string $_code = 'bobgo'; + protected bool $_isFixed = true; + private ResultFactory $rateResultFactory; + private MethodFactory $rateMethodFactory; public function __construct( ScopeConfigInterface $scopeConfig, - \Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory $rateErrorFactory, - Logger $logger, - ZendClientFactory $httpClientFactory, - array $data = [] - ) { - $this->scopeConfig = $scopeConfig; - $this->httpClientFactory = $httpClientFactory; - $this->logger = $logger; + ErrorFactory $rateErrorFactory, + LoggerInterface $logger, + ResultFactory $rateResultFactory, + MethodFactory $rateMethodFactory, + array $data = [] + ) + { parent::__construct($scopeConfig, $rateErrorFactory, $logger, $data); + $this->rateResultFactory = $rateResultFactory; + $this->rateMethodFactory = $rateMethodFactory; } + /** + * Custom Shipping Rates Collector + * + * @param RateRequest $request + * @return \Magento\Shipping\Model\Rate\Result|bool + */ public function collectRates(RateRequest $request) { - $this->logger->info('BobGo collectRates method called'); - if (!$this->getConfigFlag('active')) { - $this->logger->info('BobGo is not active'); return false; } - - $this->logger->info('BobGo is active, proceeding with rate collection'); - - $result = $this->_rateFactory->create(); - - // Prepare request data for API call - $params = [ - 'dest_country_id' => $request->getDestCountryId(), - 'dest_region_id' => $request->getDestRegionId(), - 'dest_postcode' => $request->getDestPostcode(), - 'package_weight' => $request->getPackageWeight(), - 'package_value' => $request->getPackageValue(), - 'package_qty' => $request->getPackageQty(), - ]; - - $this->logger->info('Request parameters: ' . json_encode($params)); - - try { - $apiResponse = $this->_fetchRatesFromApi($params); - $this->logger->info('API response: ' . json_encode($apiResponse)); - - if ($apiResponse && isset($apiResponse['rates']) && !empty($apiResponse['rates'])) { - foreach ($apiResponse['rates'] as $rateData) { - $rate = $this->_rateMethodFactory->create(); - $rate->setCarrier($this->_code); - $rate->setCarrierTitle($this->getConfigData('title')); - $rate->setMethod($rateData['method']); - $rate->setMethodTitle($rateData['method_title']); - $rate->setPrice($rateData['price']); - $rate->setCost($rateData['cost']); - $result->append($rate); - } - } else { - $this->logger->info('No rates returned from API'); - $error = $this->_rateErrorFactory->create(); - $error->setCarrier($this->_code); - $error->setCarrierTitle($this->getConfigData('title')); - $error->setErrorMessage($this->getConfigData('specificerrmsg')); - return $error; - } - } catch (\Exception $e) { - $this->logger->error('Error fetching rates from API: ' . $e->getMessage()); - $error = $this->_rateErrorFactory->create(); - $error->setCarrier($this->_code); - $error->setCarrierTitle($this->getConfigData('title')); - $error->setErrorMessage($this->getConfigData('specificerrmsg')); - return $error; - } - + /** @var Method $method */ + $method = $this->rateMethodFactory->create(); + $method->setCarrier($this->_code); + $method->setCarrierTitle($this->getConfigData('title')); + $method->setMethod($this->_code); + $method->setMethodTitle($this->getConfigData('name')); + $shippingCost = (float)$this->getConfigData('shipping_cost'); + $method->setPrice($shippingCost); + $method->setCost($shippingCost); + /** @var Result $result */ + $result = $this->rateResultFactory->create(); + $result->append($method); return $result; } - protected function _fetchRatesFromApi($params) - { - $url = 'https://api.dev.bobgo.co.za/rates-at-checkout/magento'; - $client = $this->httpClientFactory->create(); - $client->setUri($url); - $client->setConfig(['timeout' => 30]); - $client->setHeaders(['Content-Type' => 'application/json']); - $client->setMethod(\Zend_Http_Client::POST); - $client->setRawData(json_encode($params), 'application/json'); - - try { - $response = $client->request(); - $responseBody = $response->getBody(); - - // Log the response body - $this->logger->info('Response body: ' . var_export($responseBody, true)); - - if ($responseBody === null) { - $this->logger->error('API response body is null'); - return false; - } - - if ($response->isSuccessful()) { - return json_decode($responseBody, true); - } else { - $this->logger->error('API request failed with status: ' . $response->getStatus()); - } - } catch (\Exception $e) { - $this->logger->error('Exception during API request: ' . $e->getMessage()); - } - - return false; - } - - public function getAllowedMethods() + public function getAllowedMethods(): array { return [$this->_code => $this->getConfigData('name')]; } - } - - diff --git a/Observer/ConfigChangeObserver.php b/Observer/ConfigChangeObserver.php index 47c31a9f0576d102aac03581aa1fea2760eeaa58..ad1c4420a3762fe1999559d8562b63f3ce9fe2a9 100644 --- a/Observer/ConfigChangeObserver.php +++ b/Observer/ConfigChangeObserver.php @@ -1,125 +1,125 @@ <?php - -namespace BobGroup\BobGo\Observer; - -use Magento\Framework\Event\Observer; -use Magento\Framework\Event\ObserverInterface; -use Magento\Framework\App\Config\ScopeConfigInterface; -use Magento\Framework\HTTP\Client\Curl; -use Psr\Log\LoggerInterface; - -class ConfigChangeObserver implements ObserverInterface -{ - protected $scopeConfig; - protected $curl; - protected $logger; - - public function __construct( - ScopeConfigInterface $scopeConfig, - Curl $curl, - LoggerInterface $logger - ) { - $this->scopeConfig = $scopeConfig; - $this->curl = $curl; - $this->logger = $logger; - } - - public function execute(Observer $observer) - { - $sectionId = $observer->getEvent()->getSection(); - - // Ensure we're working with the 'carriers' section - if ($sectionId === 'carriers') { - $isEnabled = $this->scopeConfig->getValue('carriers/bobgo/active', \Magento\Store\Model\ScopeInterface::SCOPE_STORE); - - // Check if the extension is enabled - if ($isEnabled) { - $url = 'https://api.dev.bobgo.co.za/rates-at-checkout/magento'; - - // Prepare the payload - $payload = json_encode([ - "identifier" => "woodemo3.bobgo.co.za", - "rate" => [ - "origin" => [ - "country" => "ZA", - "postal_code" => "0181", - "province" => "GP", - "city" => "Pretoria", - "name" => null, - "address1" => "125 Dallas Avenue", - "address2" => "Newlands", - "address3" => null, - "phone" => "", - "fax" => "", - "email" => null, - "address_type" => null, - "company_name" => "" - ], - "destination" => [ - "country" => "ZA", - "postal_code" => "0181", - "province" => "GP", - "city" => "Pretoria", - "name" => null, - "address1" => null, - "address2" => "", - "address3" => null, - "phone" => "", - "fax" => "", - "email" => null, - "address_type" => null, - "company_name" => "", - "shipping_suburb" => "Elarduspark" - ], - "currency" => "ZAR", - "locale" => "en", - "items" => [ - [ - "name" => "Colours With Variants - Has dimensions - Red", - "sku" => "sku-1", - "quantity" => 2, - "price" => 500, - "vendor" => "", - "requires_shipping" => true, - "taxable" => true, - "fulfillment_service" => "manual", - "properties" => null, - "product_id" => 160824, - "grams" => 2000, - "height" => 20, - "length" => 43, - "width" => 63, - "variant_id" => 160826, - "shipping_class" => "colours", - "shipping_class_id" => 41 - ] - ] - ] - ]); - - try { - // Set headers - $this->curl->addHeader("Accept", "*/*"); - $this->curl->addHeader("Accept-Encoding", "deflate, gzip, br"); - $this->curl->addHeader("Content-Type", "application/json; charset=utf-8"); - $this->curl->addHeader("Host", "api.dev.bobgo.co.za"); - $this->curl->addHeader("User-Agent", "Magento/2.x"); - - // Send the request - $this->curl->post($url, $payload); - - // Check response status - if ($this->curl->getStatus() == 200) { - $response = $this->curl->getBody(); - $this->logger->info('Bob Go API response:', ['response' => $response]); - } else { - $status = $this->curl->getStatus(); - $this->logger->error('Bob Go API request failed.', ['status' => $status, 'url' => $url]); - } - } catch (\Exception $e) { - $this->logger->error('Bob Go API request error:', ['exception' => $e->getMessage()]); - } - } - } - } -} +// +//namespace BobGroup\BobGo\Observer; +// +//use Magento\Framework\Event\Observer; +//use Magento\Framework\Event\ObserverInterface; +//use Magento\Framework\App\Config\ScopeConfigInterface; +//use Magento\Framework\HTTP\Client\Curl; +//use Psr\Log\LoggerInterface; +// +//class ConfigChangeObserver implements ObserverInterface +//{ +// protected $scopeConfig; +// protected $curl; +// protected $logger; +// +// public function __construct( +// ScopeConfigInterface $scopeConfig, +// Curl $curl, +// LoggerInterface $logger +// ) { +// $this->scopeConfig = $scopeConfig; +// $this->curl = $curl; +// $this->logger = $logger; +// } +// +// public function execute(Observer $observer) +// { +// $sectionId = $observer->getEvent()->getSection(); +// +// // Ensure we're working with the 'carriers' section +// if ($sectionId === 'carriers') { +// $isEnabled = $this->scopeConfig->getValue('carriers/bobgo/active', \Magento\Store\Model\ScopeInterface::SCOPE_STORE); +// +// // Check if the extension is enabled +// if ($isEnabled) { +// $url = 'https://api.dev.bobgo.co.za/rates-at-checkout/magento'; +// +// // Prepare the payload +// $payload = json_encode([ +// "identifier" => "woodemo3.bobgo.co.za", +// "rate" => [ +// "origin" => [ +// "country" => "ZA", +// "postal_code" => "0181", +// "province" => "GP", +// "city" => "Pretoria", +// "name" => null, +// "address1" => "125 Dallas Avenue", +// "address2" => "Newlands", +// "address3" => null, +// "phone" => "", +// "fax" => "", +// "email" => null, +// "address_type" => null, +// "company_name" => "" +// ], +// "destination" => [ +// "country" => "ZA", +// "postal_code" => "0181", +// "province" => "GP", +// "city" => "Pretoria", +// "name" => null, +// "address1" => null, +// "address2" => "", +// "address3" => null, +// "phone" => "", +// "fax" => "", +// "email" => null, +// "address_type" => null, +// "company_name" => "", +// "shipping_suburb" => "Elarduspark" +// ], +// "currency" => "ZAR", +// "locale" => "en", +// "items" => [ +// [ +// "name" => "Colours With Variants - Has dimensions - Red", +// "sku" => "sku-1", +// "quantity" => 2, +// "price" => 500, +// "vendor" => "", +// "requires_shipping" => true, +// "taxable" => true, +// "fulfillment_service" => "manual", +// "properties" => null, +// "product_id" => 160824, +// "grams" => 2000, +// "height" => 20, +// "length" => 43, +// "width" => 63, +// "variant_id" => 160826, +// "shipping_class" => "colours", +// "shipping_class_id" => 41 +// ] +// ] +// ] +// ]); +// +// try { +// // Set headers +// $this->curl->addHeader("Accept", "*/*"); +// $this->curl->addHeader("Accept-Encoding", "deflate, gzip, br"); +// $this->curl->addHeader("Content-Type", "application/json; charset=utf-8"); +// $this->curl->addHeader("Host", "api.dev.bobgo.co.za"); +// $this->curl->addHeader("User-Agent", "Magento/2.x"); +// +// // Send the request +// $this->curl->post($url, $payload); +// +// // Check response status +// if ($this->curl->getStatus() == 200) { +// $response = $this->curl->getBody(); +// $this->logger->info('Bob Go API response:', ['response' => $response]); +// } else { +// $status = $this->curl->getStatus(); +// $this->logger->error('Bob Go API request failed.', ['status' => $status, 'url' => $url]); +// } +// } catch (\Exception $e) { +// $this->logger->error('Bob Go API request error:', ['exception' => $e->getMessage()]); +// } +// } +// } +// } +//} diff --git a/composer.json b/composer.json index f908f860b03f7504ea1e174a657b88744791603d..219b845785a309ae522025e5d28fcd07e1232fa5 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "registration.php" ], "psr-4": { - "Plugin\\": "" + "BobGroup\\BobGo\\": "" } } } diff --git a/etc/adminhtml/events.xml b/etc/adminhtml/events.xml index 4cc2e52b3d3fd11d719cfcb6045fa566ff778739..5e9cd837617fc16fbc999d43a6dc0b2e58d725e5 100644 --- a/etc/adminhtml/events.xml +++ b/etc/adminhtml/events.xml @@ -1,6 +1,6 @@ -<?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> +<!--<?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 8c11255bf2714a7d282b6e1d34bb8e77604fb615..3e7c5b650e8301f66e7e811e5ef474604d388d50 100644 --- a/etc/adminhtml/system.xml +++ b/etc/adminhtml/system.xml @@ -1,44 +1,40 @@ <?xml version="1.0"?> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd"> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd"> <system> - <section id="carriers" translate="label" type="text" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="1"> - <group id="bobgo" translate="label" type="text" sortOrder="2" showInDefault="1" showInWebsite="1" showInStore="1"> + <section id="carriers"> + <group id="bobgo" translate="label" type="text" sortOrder="0" showInDefault="1" showInWebsite="1" showInStore="1"> <label>Bob Go</label> - <field id="active" translate="label" type="select" sortOrder="1" showInDefault="1" showInWebsite="1" showInStore="0"> - <label>Enable Extension</label> + <field id="active" translate="label" type="select" sortOrder="10" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1"> + <label>Enabled</label> <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="title" translate="label" type="text" sortOrder="20" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1"> + <label>Title</label> </field> - <field id="sallowspecific" translate="label" type="select" sortOrder="90" showInDefault="1" showInWebsite="1" showInStore="0"> + <field id="name" translate="label" type="text" sortOrder="30" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1"> + <label>Method Name</label> + </field> + <field id="shipping_cost" translate="label" type="text" sortOrder="40" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1"> + <label>Shipping Cost</label> + <validate>validate-number validate-zero-or-greater</validate> + </field> + <field id="sallowspecific" translate="label" type="select" sortOrder="50" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1"> <label>Ship to Applicable Countries</label> - <frontend_class>shipping-applicable-country</frontend_class> - <source_model>Magento\Shipping\Model\Config\Source\Allspecificcountries</source_model> + <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="60" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1"> <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"> - <label>Show Method if Not Applicable</label> - <frontend_class>shipping-skip-hide</frontend_class> + <field id="showmethod" translate="label" type="select" sortOrder="70" showInDefault="1" showInWebsite="1" showInStore="1"> + <label>Show Method if not applicable</label> <source_model>Magento\Config\Model\Config\Source\Yesno</source_model> + <frontend_class>shipping-skip-hide</frontend_class> </field> - <field id="unit_of_measure" translate="label" type="select" sortOrder="73" showInDefault="1" showInWebsite="1"> - <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"> - <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 id="sort_order" translate="label" type="text" sortOrder="80" showInDefault="1" showInWebsite="1" showInStore="1" canRestore="1"> + <label>Sort Order</label> </field> </group> </section> diff --git a/etc/config.xml b/etc/config.xml index bb05ba5b42f62c0b8ba5c13bc9394bb72d2da2a7..b3119b9cc761a713160e1f6ec83545b1aa0b1424 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -21,21 +21,19 @@ <!-- </default>--> <!--</config>--> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd"> - <default> - <carriers> - <bobgo> - <active>1</active> - <model>BobGroup\BobGo\Model\Carrier\BobGo</model> - <title>Bob Go</title> - <name>BobGo</name> - <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> - <sallowspecific>0</sallowspecific> - <showmethod>1</showmethod> - <unit_of_measure>KGS</unit_of_measure> - <max_package_weight>300</max_package_weight> - <additional_info>0</additional_info> - </bobgo> - </carriers> - </default> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Store:etc/config.xsd"> +<default> + <carriers> + <bobgo> + <active>1</active> + <title>Bob Go</title> + <name>BobGo</name> + <shipping_cost>10</shipping_cost> + <sallowspecific>0</sallowspecific> + <sort_order>15</sort_order> + <model>BobGroup\BobGo\Model\Carrier\BobGo</model> + </bobgo> + </carriers> +</default> </config> diff --git a/etc/di.xml b/etc/di.xml index bb1ced220df8aea7afa1653f37ccaeaca7ae5176..4e63e92e9e2110d347b4b828e1097c1cdf59bac5 100644 --- a/etc/di.xml +++ b/etc/di.xml @@ -1,36 +1,36 @@ -<?xml version="1.0"?> +<!--<?xml version="1.0"?>--> +<!--<!–<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">–>--> +<!--<!– <type name="BobGroup\BobGo\Logger\Logger">–>--> +<!--<!– <arguments>–>--> +<!--<!– <argument name="name" xsi:type="string">bobgo</argument>–>--> +<!--<!– <argument name="handlers" xsi:type="array">–>--> +<!--<!– <item name="stream" xsi:type="object">BobGroup\BobGo\Logger\Handler</item>–>--> +<!--<!– </argument>–>--> +<!--<!– </arguments>–>--> +<!--<!– </type>–>--> +<!--<!– <type name="BobGroup\BobGo\Observer\ConfigChangeObserver">–>--> +<!--<!– <arguments>–>--> +<!--<!– <argument name="curl" xsi:type="object">Magento\Framework\HTTP\Client\Curl</argument>–>--> +<!--<!– </arguments>–>--> +<!--<!– </type>–>--> + +<!--<!–</config>–>--> + <!--<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">--> -<!-- <type name="BobGroup\BobGo\Logger\Logger">--> +<!-- <type name="BobGroup\BobGo\Logger\Handler">--> <!-- <arguments>--> -<!-- <argument name="name" xsi:type="string">bobgo</argument>--> -<!-- <argument name="handlers" xsi:type="array">--> -<!-- <item name="stream" xsi:type="object">BobGroup\BobGo\Logger\Handler</item>--> -<!-- </argument>--> +<!-- <argument name="fileName" xsi:type="string">/var/log/bobgo_plugin.log</argument>--> +<!-- <argument name="loggerType" xsi:type="number">100</argument>--> <!-- </arguments>--> <!-- </type>--> -<!-- <type name="BobGroup\BobGo\Observer\ConfigChangeObserver">--> + +<!-- <type name="BobGroup\BobGo\Logger\Logger">--> <!-- <arguments>--> -<!-- <argument name="curl" xsi:type="object">Magento\Framework\HTTP\Client\Curl</argument>--> +<!-- <argument name="handlers" xsi:type="array">--> +<!-- <item name="bobgo" xsi:type="object">BobGroup\BobGo\Logger\Handler</item>--> +<!-- </argument>--> <!-- </arguments>--> <!-- </type>--> - <!--</config>--> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> - <type name="BobGroup\BobGo\Logger\Handler"> - <arguments> - <argument name="fileName" xsi:type="string">/var/log/bobgo_plugin.log</argument> - <argument name="loggerType" xsi:type="number">100</argument> - </arguments> - </type> - - <type name="BobGroup\BobGo\Logger\Logger"> - <arguments> - <argument name="handlers" xsi:type="array"> - <item name="bobgo" xsi:type="object">BobGroup\BobGo\Logger\Handler</item> - </argument> - </arguments> - </type> -</config> - diff --git a/etc/env.php b/etc/env.php index f8a2cb3307a60f09363e0c9d22f9f5fb6c04568e..5698878c54266d3d516ff644d1e2ef0f574cb220 100644 --- a/etc/env.php +++ b/etc/env.php @@ -1,19 +1,19 @@ <?php -return [ - 'backend' => [ - 'frontName' => 'admin' - ], - 'install' => [ - 'date' => 'Wed, 15 Jan 2020 00:00:00 +0000' - ], - 'system' => [ - 'default' => [ - 'dev' => [ - 'log' => [ - 'active' => '1' - ] - ] - ] - ], - // Other configurations... -]; +//return [ +// 'backend' => [ +// 'frontName' => 'admin' +// ], +// 'install' => [ +// 'date' => 'Wed, 15 Jan 2020 00:00:00 +0000' +// ], +// 'system' => [ +// 'default' => [ +// 'dev' => [ +// 'log' => [ +// 'active' => '1' +// ] +// ] +// ] +// ], +// // Other configurations... +//]; diff --git a/etc/module.xml b/etc/module.xml index 29ed17fd27591ebe6a2c308765ecda5e0dc09bfb..a02c0efe00f9e0fdc228e80cf8657c81eaff4c50 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -19,14 +19,19 @@ <!-- </module>--> <!--</config>--> -<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> -<module name="BobGroup_BobGo" setup_version="1.0.0"> - <sequence> - <module name="Magento_Config"/> - <module name="Magento_Shipping"/> - </sequence> -</module> -</config> +<!--<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">--> +<!--<module name="BobGroup_BobGo" setup_version="1.0.0">--> +<!-- <sequence>--> +<!-- <module name="Magento_Config"/>--> +<!-- <module name="Magento_Shipping"/>--> +<!-- </sequence>--> +<!--</module>--> +<!--</config>--> +<!-- <?xml version="1.0"?>--> +<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd"> +<module name="BobGroup_BobGo"/> +</config> diff --git a/registration.php b/registration.php index d8ff5a840e4d2d57e7de9f29ae6764db98a3687f..3b65cb39d60ac0e5b8a4979dd529ceaca9b14e5a 100644 --- a/registration.php +++ b/registration.php @@ -1,6 +1,10 @@ <?php -\Magento\Framework\Component\ComponentRegistrar::register( - \Magento\Framework\Component\ComponentRegistrar::MODULE, +declare(strict_types=1); + +use Magento\Framework\Component\ComponentRegistrar; + +ComponentRegistrar::register( + ComponentRegistrar::MODULE, 'BobGroup_BobGo', __DIR__ );