diff --git a/Block/System/Config/Form/Field/Version.php b/Block/System/Config/Form/Field/Version.php index 5d071801a406da9f220bf1fd0093996f8eeb5b3d..a98a00a41d2c1aab88dce26b916e386ce7c11dc7 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 d0627eefd27a235e7b0b5b498f8e22ab4fd1a215..85a24f2acfd9378effc0f68de7edca9ffaf1b72a 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/Carrier/BobGo.php b/Model/Carrier/BobGo.php index e02f0a1a39d38f11b5df8096dab9150f14add44a..97f55764c2938644d1e927e1f8e5a73b2ab0d3db 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) diff --git a/Model/Source/Generic.php b/Model/Source/Generic.php index 674f68706a72978fd580ecb1f6ebd157e78b9bfc..f5eb3943cd1c7c0f71cc2af44e6361fb0adb1006 100644 --- a/Model/Source/Generic.php +++ b/Model/Source/Generic.php @@ -2,19 +2,56 @@ namespace BobGroup\BobGo\Model\Source; + +use Magento\Framework\Data\OptionSourceInterface; +use BobGroup\BobGo\Model\Carrier\BobGo; + /** - * Bob Go Free Method source implementation + * bobgo generic source implementation */ -class Freemethod extends Method +class Generic implements OptionSourceInterface { /** - * {@inheritdoc} + * @var BobGo + */ + protected BobGo $_shippingBobGo; + + /** + * Carrier code + * @var string + */ + protected string $_code = ''; + + /** + * @param BobGo $shippingBobGo + */ + public function __construct(BobGo $shippingBobGo) + { + $this->_shippingBobGo = $shippingBobGo; + } + + /** + * Returns array to be used in multiselect on back-end + * @return array */ public function toOptionArray() { - //Returns an array of arrays, each of which has a 'value' and a 'label'. The 'value' is the code for the shipping method, and the 'label' is the name of the shipping method. - $arr = parent::toOptionArray(); - array_unshift($arr, ['value' => '', 'label' => __('None')]); + $configData = $this->_shippingBobGo->getCode($this->_code); + $arr = []; + if ($configData) { + $arr = array_map( + function ($code, $title) { + return [ + 'value' => $code, + 'label' => $title + ]; + }, + array_keys($configData), + $configData + ); + } + return $arr; } + } diff --git a/etc/config.xml b/etc/config.xml index 866d2c7b45daf6b77749a6298aec57749c643c13..9e4c9863ecbc0341accbf7d01547c7114a5ff3a2 100644 --- a/etc/config.xml +++ b/etc/config.xml @@ -9,7 +9,7 @@ <carriers> <bobgo> - <active>0</active> + <active>1</active> <price>0.00</price> <model>BobGroup\BobGo\Model\Carrier\BobGo</model> <name>Fixed</name> diff --git a/etc/module.xml b/etc/module.xml index 5e262c840987b62de4f4f48d374ffc5ad243f1de..fe2b36da4d6bad5e35cb60c85d1f1ff05d245001 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -2,7 +2,7 @@ <!-- /** * @category Bob Go - * @package bobgo_CustomShipping + * @package BobGo * @author Bob Go */ -->