Skip to content
Snippets Groups Projects
Commit 5fd74366 authored by Gundo Sifhufhi's avatar Gundo Sifhufhi
Browse files

Add Unit measures to (uafrica magento) extension in Admin Panel. get predefined methods.

parent 9839b579
No related branches found
No related tags found
No related merge requests found
<?php
namespace uafrica\Customshipping\Model\Source;
class Dropoff extends Generic
{
/**
* Carrier code
* @var string
*/
protected string $_code = 'dropoff';
}
<?php
namespace uafrica\customshipping\Model\Source;
use uafrica\Customshipping\Model\Carrier\Customshipping;
/**
* uAfrica generic source implementation
*/
class Generic implements \Magento\Framework\Data\OptionSourceInterface
{
/**
* @var Customshipping
*/
protected Customshipping $_shippingCustomshipping;
/**
* Carrier code
* @var string
*/
protected string $_code = '';
/**
* @param Customshipping $shippingCustomshipping
*/
public function __construct(Customshipping $shippingCustomshipping)
{
$this->_shippingCustomshipping = $shippingCustomshipping;
}
/**
* Returns array to be used in multiselect on back-end
* @return array
*/
public function toOptionArray()
{
$configData = $this->_shippingCustomshipping->getCode($this->_code);
$arr = [];
if ($configData) {
$arr = array_map(
function ($code, $title) {
return [
'value' => $code,
'label' => $title
];
},
array_keys($configData),
$configData
);
}
return $arr;
}
}
<?php
namespace uafrica\Customshipping\Model\Source;
class Method extends Generic
{
/**
* Carrier code
* @var string
*/
protected string $_code = 'method';
}
<?php
namespace uafrica\Customshipping\Model\Source;
class Packaging extends Generic
{
/**
* Carrier code
* @var string
*/
protected string $_code = 'packaging';
}
<?php
namespace uafrica\Customshipping\Model\Source;
class Unitofmeasure extends Generic
{
/**
* Carrier code
* @var string
*/
protected string $_code = 'unit_of_measure';
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment