public function getTaxRates()
    {
        $rates = [];
        /** @var \Magento\Tax\Model\Calculation\Rate $rate */
        foreach ($this->taxRates as $rate) {
            $zipCodeType      = self::ZIP_CODE_TYPE_ALL;
            $zipCodePattern   = '';
            $zipCodeRangeFrom = '';
            $zipCodeRangeTo   = '';

            if ($rate->getZipIsRange()) {
                $zipCodeType      = self::ZIP_CODE_TYPE_RANGE;
                $zipCodeRangeFrom = $rate->getZipFrom();
                $zipCodeRangeTo   = $rate->getZipTo();
            } elseif ($rate->getTaxPostcode() && $rate->getTaxPostcode() != '*') {
                $zipCodeType    = self::ZIP_CODE_TYPE_PATTERN;
                $zipCodePattern = $rate->getTaxPostcode();
            }

            $state    = '';
            $regionId = $rate->getTaxRegionId();

            if ($regionId) {
                /** @var \Magento\Directory\Model\Region $region */
                $region = $this->regionCollection->getItemById($regionId);
                $state  = $this->regionHelper->getIsoStateByMagentoRegion(
                    new DataObject(
                        [
                            'region_code' => $region->getCode(),
                            'country_id'  => $rate->getTaxCountryId()
                        ]
                    )
                );
            }

            $rates[] = [
                'id'                 => $rate->getId(),
                'key'                => $rate->getId(),
                'display_name'       => $rate->getCode(),
                'tax_percent'        => round($rate->getRate(), 4),
                'country'            => $rate->getTaxCountryId(),
                'state'              => $state,
                'zipcode_type'       => $zipCodeType,
                'zipcode_pattern'    => $zipCodePattern,
                'zipcode_range_from' => $zipCodeRangeFrom,
                'zipcode_range_to'   => $zipCodeRangeTo
            ];
        }

        return $rates;
    }
public function getTaxRates()
    {
        $rates = [];
        /** @var \Magento\Tax\Model\Calculation\Rate $rate */
        foreach ($this->taxRates as $rate) {
            $zipCodeType      = self::ZIP_CODE_TYPE_ALL;
            $zipCodePattern   = '';
            $zipCodeRangeFrom = '';
            $zipCodeRangeTo   = '';

            if ($rate->getZipIsRange()) {
                $zipCodeType      = self::ZIP_CODE_TYPE_RANGE;
                $zipCodeRangeFrom = $rate->getZipFrom();
                $zipCodeRangeTo   = $rate->getZipTo();
            } elseif ($rate->getTaxPostcode() && $rate->getTaxPostcode() != '*') {
                $zipCodeType    = self::ZIP_CODE_TYPE_PATTERN;
                $zipCodePattern = $rate->getTaxPostcode();
            }

            $state    = '';
            $regionId = $rate->getTaxRegionId();

            if ($regionId) {
                /** @var \Magento\Directory\Model\Region $region */
                $region = $this->regionCollection->getItemById($regionId);
                $state  = $this->regionHelper->getIsoStateByMagentoRegion(
                    new DataObject(
                        [
                            'region_code' => $region->getCode(),
                            'country_id'  => $rate->getTaxCountryId()
                        ]
                    )
                );
            }

            $rates[] = [
                'id'                 => $rate->getId(),
                'key'                => $rate->getId(),
                'display_name'       => $rate->getCode(),
                'tax_percent'        => round($rate->getRate(), 4),
                'country'            => $rate->getTaxCountryId(),
                'state'              => $state,
                'zipcode_type'       => $zipCodeType,
                'zipcode_pattern'    => $zipCodePattern,
                'zipcode_range_from' => $zipCodeRangeFrom,
                'zipcode_range_to'   => $zipCodeRangeTo
            ];
        }

        return $rates;
    }
public function getTaxRates ( ) { $ rates = [ ] ; /** @var \Magento\Tax\Model\Calculation\Rate $rate */ foreach ( $ this -> taxRates as $ rate ) { $ zipCodeType = self :: ZIP_CODE_TYPE_ALL ; $ zipCodePattern = '' ; $ zipCodeRangeFrom = '' ; $ zipCodeRangeTo = '' ; if ( $ rate -> getZipIsRange ( ) ) { $ zipCodeType = self :: ZIP_CODE_TYPE_RANGE ; $ zipCodeRangeFrom = $ rate -> getZipFrom ( ) ; $ zipCodeRangeTo = $ rate -> getZipTo ( ) ; } elseif ( $ rate -> getTaxPostcode ( ) && $ rate -> getTaxPostcode ( ) != '*' ) { $ zipCodeType = self :: ZIP_CODE_TYPE_PATTERN ; $ zipCodePattern = $ rate -> getTaxPostcode ( ) ; } $ state = '' ; $ regionId = $ rate -> getTaxRegionId ( ) ; if ( $ regionId ) { /** @var \Magento\Directory\Model\Region $region */ $ region = $ this -> regionCollection -> getItemById ( $ regionId ) ; $ state = $ this -> regionHelper -> getIsoStateByMagentoRegion ( new DataObject ( [ 'region_code' => $ region -> getCode ( ) , 'country_id' => $ rate -> getTaxCountryId ( ) ] ) ) ; } $ rates [ ] = [ 'id' => $ rate -> getId ( ) , 'key' => $ rate -> getId ( ) , 'display_name' => $ rate -> getCode ( ) , 'tax_percent' => round ( $ rate -> getRate ( ) , 4 ) , 'country' => $ rate -> getTaxCountryId ( ) , 'state' => $ state , 'zipcode_type' => $ zipCodeType , 'zipcode_pattern' => $ zipCodePattern , 'zipcode_range_from' => $ zipCodeRangeFrom , 'zipcode_range_to' => $ zipCodeRangeTo ] ; } return $ rates ; }
Retrieve Magento tax rates for
Merchant API to pick up

@return array
Retrieve Magento tax rates for Merchant API to pick up