private function getAllowedShippingCountriesRaw()
    {
        $allowedCountries = array_fill_keys($this->mainShipHelper->getMageShippingCountries(), []);
        $carriers         = $this->mainShipHelper->getActiveCarriers();
        $countries        = [];

        /**
         * @var AbstractCarrier $carrier
         */
        foreach ($carriers as $carrier) {
            /* skip shopgate cause its a container carrier */
            if ($carrier->getCarrierCode() === Shipping\Carrier\Shopgate::CODE) {
                continue;
            }

            /* if any carrier is using the allowed_countries collection, merge this into the result */
            if ($carrier->getConfigData('sallowspecific') === '0') {
                $countries = array_merge_recursive($countries, $allowedCountries);
                continue;
            }

            /* fetching active shipping targets from rates direct from the database */
            if ($carrier->getCarrierCode() === Shipping\Carrier\TableRate::CODE) {
                $collection    = $this->tableRate->getTableRateCollection();
                $countryHolder = [];

                /** @var Tablerate $rate */
                foreach ($collection as $rate) {
                    $countryHolder[$rate->getData('dest_country_id')][$rate->getData('dest_region') ? : 'All'] = true;
                }
                $countries = array_merge_recursive($countryHolder, $countries);
                continue;
            }

            $specificCountries = $carrier->getConfigData('specificcountry');
            $countries         = array_merge_recursive(
                $countries,
                array_fill_keys(explode(",", $specificCountries), [])
            );
        }

        foreach ($countries as $countryCode => $item) {
            if (!isset($allowedCountries[$countryCode])) {
                unset($countries[$countryCode]);
            }
        }

        return $countries;
    }
private function getAllowedShippingCountriesRaw()
    {
        $allowedCountries = array_fill_keys($this->mainShipHelper->getMageShippingCountries(), []);
        $carriers         = $this->mainShipHelper->getActiveCarriers();
        $countries        = [];

        /**
         * @var AbstractCarrier $carrier
         */
        foreach ($carriers as $carrier) {
            /* skip shopgate cause its a container carrier */
            if ($carrier->getCarrierCode() === Shipping\Carrier\Shopgate::CODE) {
                continue;
            }

            /* if any carrier is using the allowed_countries collection, merge this into the result */
            if ($carrier->getConfigData('sallowspecific') === '0') {
                $countries = array_merge_recursive($countries, $allowedCountries);
                continue;
            }

            /* fetching active shipping targets from rates direct from the database */
            if ($carrier->getCarrierCode() === Shipping\Carrier\TableRate::CODE) {
                $collection    = $this->tableRate->getTableRateCollection();
                $countryHolder = [];

                /** @var Tablerate $rate */
                foreach ($collection as $rate) {
                    $countryHolder[$rate->getData('dest_country_id')][$rate->getData('dest_region') ? : 'All'] = true;
                }
                $countries = array_merge_recursive($countryHolder, $countries);
                continue;
            }

            $specificCountries = $carrier->getConfigData('specificcountry');
            $countries         = array_merge_recursive(
                $countries,
                array_fill_keys(explode(",", $specificCountries), [])
            );
        }

        foreach ($countries as $countryCode => $item) {
            if (!isset($allowedCountries[$countryCode])) {
                unset($countries[$countryCode]);
            }
        }

        return $countries;
    }
private function getAllowedShippingCountriesRaw ( ) { $ allowedCountries = array_fill_keys ( $ this -> mainShipHelper -> getMageShippingCountries ( ) , [ ] ) ; $ carriers = $ this -> mainShipHelper -> getActiveCarriers ( ) ; $ countries = [ ] ; /**
         * @var AbstractCarrier $carrier
         */ foreach ( $ carriers as $ carrier ) { /* skip shopgate cause its a container carrier */ if ( $ carrier -> getCarrierCode ( ) === Shipping \ Carrier \ Shopgate :: CODE ) { continue ; } /* if any carrier is using the allowed_countries collection, merge this into the result */ if ( $ carrier -> getConfigData ( 'sallowspecific' ) === '0' ) { $ countries = array_merge_recursive ( $ countries , $ allowedCountries ) ; continue ; } /* fetching active shipping targets from rates direct from the database */ if ( $ carrier -> getCarrierCode ( ) === Shipping \ Carrier \ TableRate :: CODE ) { $ collection = $ this -> tableRate -> getTableRateCollection ( ) ; $ countryHolder = [ ] ; /** @var Tablerate $rate */ foreach ( $ collection as $ rate ) { $ countryHolder [ $ rate -> getData ( 'dest_country_id' ) ] [ $ rate -> getData ( 'dest_region' ) ? : 'All' ] = true ; } $ countries = array_merge_recursive ( $ countryHolder , $ countries ) ; continue ; } $ specificCountries = $ carrier -> getConfigData ( 'specificcountry' ) ; $ countries = array_merge_recursive ( $ countries , array_fill_keys ( explode ( "," , $ specificCountries ) , [ ] ) ) ; } foreach ( $ countries as $ countryCode => $ item ) { if ( ! isset ( $ allowedCountries [ $ countryCode ] ) ) { unset ( $ countries [ $ countryCode ] ) ; } } return $ countries ; }
Collects the raw allowed countries from Magento
Collects the raw allowed countries from Magento