Skip to content
Snippets Groups Projects
Select Git revision
  • 9d98251395eb70a9edeb2d8abd6cb6bfcd9a40ea
  • dev default protected
  • prod protected
  • 1.0.58
  • 1.0.57
  • 1.0.52
  • 1.0.56
  • 1.0.51
  • 1.0.50
  • 1.0.33
  • 1.0.32
  • 1.0.31
  • 1.0.30
  • 1.0.29
  • 1.0.28
  • 1.0.27
  • 1.0.26
  • 1.0.25
  • 1.0.24
  • 1.0.23
  • 1.0.22
  • 1.0.21
  • 1.0.20
23 results

Customshipping.php

Blame
  • Customshipping.php 26.44 KiB
    <?php
    declare(strict_types=1);
    
    namespace uafrica\Customshipping\Model\Carrier;
    
    use DateTime;
    use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
    use Magento\CatalogInventory\Api\StockRegistryInterface;
    use Magento\Directory\Helper\Data;
    use Magento\Directory\Model\CountryFactory;
    use Magento\Directory\Model\CurrencyFactory;
    use Magento\Directory\Model\RegionFactory;
    use Magento\Framework\App\Config\ScopeConfigInterface;
    use Magento\Framework\Controller\Result\JsonFactory;
    use Magento\Framework\DataObject;
    use Magento\Framework\Exception\LocalizedException;
    use Magento\Framework\HTTP\Client\CurlFactory;
    use Magento\Framework\Module\Dir\Reader;
    use Magento\Framework\Xml\Security;
    use Magento\Quote\Model\Quote\Address\RateRequest;
    use Magento\Quote\Model\Quote\Address\RateResult\ErrorFactory;
    use Magento\Quote\Model\Quote\Address\RateResult\MethodFactory;
    use Magento\Shipping\Model\Carrier\AbstractCarrier;
    use Magento\Shipping\Model\Carrier\AbstractCarrierOnline;
    use Magento\Shipping\Model\Rate\Result;
    use Magento\Shipping\Model\Rate\ResultFactory;
    use Magento\Shipping\Model\Simplexml\ElementFactory;
    use Magento\Shipping\Model\Tracking\Result\StatusFactory;
    use Magento\Store\Model\ScopeInterface;
    use Magento\Store\Model\StoreManagerInterface;
    use Psr\Log\LoggerInterface;
    
    /**
     * uAfrica shipping implementation
     * @category   uafrica
     * @package    uafrica_Customshipping
     * @author     info@bob.co.za
     * @website    https://www.bob.co.za
     * @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
     * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
     * @SuppressWarnings(PHPMD.TooManyFields)
     */
    class Customshipping extends AbstractCarrierOnline implements \Magento\Shipping\Model\Carrier\CarrierInterface
    {
        /**
         * Code of the carrier
         *`
         * @var string
         */
        public const CODE = 'uafrica';
    
        /** Tracking Endpoint */
        const TRACKING = 'https://api.dev.ship.uafrica.com/tracking?channel=localhost&tracking_reference=';
        /*** RATES API Endpoint*/
        const RATES_ENDPOINT = 'https://api.dev.ship.uafrica.com/rates-at-checkout/woocommerce';
    
    
        /**
         * Code of the carrier
         *
         * @var string
         */
        protected $_code = self::CODE;
    
        /**
         * Types of rates, order is important
         *
         * @var array
         */
        protected $_ratesOrder = [