public function collectRates(Mage_Shipping_Model_Rate_Request $request)
    {
        // Check if this method is active
        if (!$this->getConfigFlag('active')) {
            return false;
        }

        // Check if this method is even applicable (shipping from Australia)
        $origCountry = Mage::getStoreConfig('shipping/origin/country_id', $request->getStore());

        if ($origCountry != Fontis_Australia_Helper_Data::AUSTRALIA_COUNTRY_CODE) {
            return false;
        }

        if ($this->_client == null) {
            return false;
        }

        $fromPostcode = str_pad((int)Mage::getStoreConfig('shipping/origin/postcode', $this->getStore()), 4, '0', STR_PAD_LEFT);
        $toPostcode = str_pad((int)$request->getDestPostcode(), 4, '0', STR_PAD_LEFT);

        $destCountry = $request->getDestCountryId();

        if (!$destCountry) {
            $destCountry = Fontis_Australia_Helper_Data::AUSTRALIA_COUNTRY_CODE;
        }

        /** @var Fontis_Australia_Helper_Australiapost $helper */
        $helper = Mage::helper('australia/australiapost');

        $weight = (float) $request->getPackageWeight();
        $length = (int)$helper->getAttribute($request, 'length');
        $width = (int)$helper->getAttribute($request, 'width');
        $height = (int)$helper->getAttribute($request, 'height');

        $extraCover = max((int)$request->getPackageValue(), self::EXTRA_COVER_LIMIT);

        $config = array(
            'from_postcode' => $fromPostcode,
            'to_postcode' => $toPostcode,
            'length' => $length,
            'width' => $width,
            'height' => $height,
            'weight' => $weight,
            'country_code' => $destCountry
        );
        $this->_getQuotes($extraCover, $config);

        $_result = $this->_result->asArray();
        if (empty($_result)) {
            return false;
        }

        return $this->_result;
    }
public function collectRates(Mage_Shipping_Model_Rate_Request $request)
    {
        // Check if this method is active
        if (!$this->getConfigFlag('active')) {
            return false;
        }

        // Check if this method is even applicable (shipping from Australia)
        $origCountry = Mage::getStoreConfig('shipping/origin/country_id', $request->getStore());

        if ($origCountry != Fontis_Australia_Helper_Data::AUSTRALIA_COUNTRY_CODE) {
            return false;
        }

        if ($this->_client == null) {
            return false;
        }

        $fromPostcode = str_pad((int)Mage::getStoreConfig('shipping/origin/postcode', $this->getStore()), 4, '0', STR_PAD_LEFT);
        $toPostcode = str_pad((int)$request->getDestPostcode(), 4, '0', STR_PAD_LEFT);

        $destCountry = $request->getDestCountryId();

        if (!$destCountry) {
            $destCountry = Fontis_Australia_Helper_Data::AUSTRALIA_COUNTRY_CODE;
        }

        /** @var Fontis_Australia_Helper_Australiapost $helper */
        $helper = Mage::helper('australia/australiapost');

        $weight = (float) $request->getPackageWeight();
        $length = (int)$helper->getAttribute($request, 'length');
        $width = (int)$helper->getAttribute($request, 'width');
        $height = (int)$helper->getAttribute($request, 'height');

        $extraCover = max((int)$request->getPackageValue(), self::EXTRA_COVER_LIMIT);

        $config = array(
            'from_postcode' => $fromPostcode,
            'to_postcode' => $toPostcode,
            'length' => $length,
            'width' => $width,
            'height' => $height,
            'weight' => $weight,
            'country_code' => $destCountry
        );
        $this->_getQuotes($extraCover, $config);

        $_result = $this->_result->asArray();
        if (empty($_result)) {
            return false;
        }

        return $this->_result;
    }
public function collectRates ( Mage_Shipping_Model_Rate_Request $ request ) { // Check if this method is active if ( ! $ this -> getConfigFlag ( 'active' ) ) { return false ; } // Check if this method is even applicable (shipping from Australia) $ origCountry = Mage :: getStoreConfig ( 'shipping/origin/country_id' , $ request -> getStore ( ) ) ; if ( $ origCountry != Fontis_Australia_Helper_Data :: AUSTRALIA_COUNTRY_CODE ) { return false ; } if ( $ this -> _client == null ) { return false ; } $ fromPostcode = str_pad ( ( int ) Mage :: getStoreConfig ( 'shipping/origin/postcode' , $ this -> getStore ( ) ) , 4 , '0' , STR_PAD_LEFT ) ; $ toPostcode = str_pad ( ( int ) $ request -> getDestPostcode ( ) , 4 , '0' , STR_PAD_LEFT ) ; $ destCountry = $ request -> getDestCountryId ( ) ; if ( ! $ destCountry ) { $ destCountry = Fontis_Australia_Helper_Data :: AUSTRALIA_COUNTRY_CODE ; } /** @var Fontis_Australia_Helper_Australiapost $helper */ $ helper = Mage :: helper ( 'australia/australiapost' ) ; $ weight = ( float ) $ request -> getPackageWeight ( ) ; $ length = ( int ) $ helper -> getAttribute ( $ request , 'length' ) ; $ width = ( int ) $ helper -> getAttribute ( $ request , 'width' ) ; $ height = ( int ) $ helper -> getAttribute ( $ request , 'height' ) ; $ extraCover = max ( ( int ) $ request -> getPackageValue ( ) , self :: EXTRA_COVER_LIMIT ) ; $ config = array ( 'from_postcode' => $ fromPostcode , 'to_postcode' => $ toPostcode , 'length' => $ length , 'width' => $ width , 'height' => $ height , 'weight' => $ weight , 'country_code' => $ destCountry ) ; $ this -> _getQuotes ( $ extraCover , $ config ) ; $ _result = $ this -> _result -> asArray ( ) ; if ( empty ( $ _result ) ) { return false ; } return $ this -> _result ; }
Collects the shipping rates for Australia Post from the REST API.

@param Mage_Shipping_Model_Rate_Request $request
@return Mage_Shipping_Model_Rate_Result|bool
Collects the shipping rates for Australia Post from the REST API .