/** * Retrieve all methods for supplied shipping data * * @todo make it ordered * @param Mage_Shipping_Model_Shipping_Method_Request $data * @return Mage_Shipping_Model_Shipping */ public function collectRates(Mage_Shipping_Model_Rate_Request $request) { if (!$request->getOrig()) { $request->setCountryId(Mage::getStoreConfig('shipping/origin/country_id', $request->getStore()))->setRegionId(Mage::getStoreConfig('shipping/origin/region_id', $request->getStore()))->setCity(Mage::getStoreConfig('shipping/origin/city', $request->getStore()))->setPostcode(Mage::getStoreConfig('shipping/origin/postcode', $request->getStore())); } $limitCarrier = $request->getLimitCarrier(); if (!$limitCarrier) { $carriers = Mage::getStoreConfig('carriers'); foreach ($carriers as $carrierCode => $carrierConfig) { $this->collectCarrierRates($carrierCode, $request); } } else { if (!is_array($limitCarrier)) { $limitCarrier = array($limitCarrier); } foreach ($limitCarrier as $carrierCode) { $carrierConfig = Mage::getStoreConfig('carriers/' . $carrierCode); if (!$carrierConfig) { continue; } $this->collectCarrierRates($carrierCode, $request); } } return $this; }
/** * 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 */ 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 = (int) Mage::getStoreConfig('shipping/origin/postcode', $this->getStore()); $toPostcode = (int) $request->getDestPostcode(); $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 = (int) $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 collectRates2(Mage_Shipping_Model_Rate_Request $request) { $storeId = $request->getStoreId(); if (!$request->getOrig()) { $request->setCountryId(Mage::getStoreConfig(self::XML_PATH_STORE_COUNTRY_ID, $request->getStore()))->setRegionId(Mage::getStoreConfig(self::XML_PATH_STORE_REGION_ID, $request->getStore()))->setCity(Mage::getStoreConfig(self::XML_PATH_STORE_CITY, $request->getStore()))->setPostcode(Mage::getStoreConfig(self::XML_PATH_STORE_ZIP, $request->getStore())); } $limitCarrier = $request->getLimitCarrier(); $carriers = Mage::getStoreConfig('carriers', $storeId); foreach ($carriers as $carrierCode => $carrierConfig) { if (!in_array($carrierCode, $limitCarrier)) { $this->collectCarrierRates($carrierCode, $request); } //echo $carrierCode; } return $this; }