Mage_Shipping_Model_Shipping Class Reference

List of all members.

Public Member Functions

 getResult ()
 setOrigData ($data)
 resetResult ()
 getConfig ()
 collectRates (Mage_Shipping_Model_Rate_Request $request)
 collectCarrierRates ($carrierCode, $request)
 collectRatesByAddress (Varien_Object $address, $limitCarrier=null)
 getCarrierByCode ($carrierCode, $storeId=null)

Protected Attributes

 $_orig = null
 $_result = null


Detailed Description

Definition at line 28 of file Shipping.php.


Member Function Documentation

collectCarrierRates ( carrierCode,
request 
)

Definition at line 125 of file Shipping.php.

00126     {
00127         $carrier = $this->getCarrierByCode($carrierCode, $request->getStoreId());
00128         if (!$carrier) {
00129             return $this;
00130         }
00131         $result = $carrier->checkAvailableShipCountries($request);
00132         if (false !== $result && !($result instanceof Mage_Shipping_Model_Rate_Result_Error)) {
00133             $result = $carrier->proccessAdditionalValidation($request);
00134         }
00135         /*
00136         * Result will be false if the admin set not to show the shipping module
00137         * if the devliery country is not within specific countries
00138         */
00139         if (false !== $result){
00140             if (!$result instanceof Mage_Shipping_Model_Rate_Result_Error) {
00141                 $result = $carrier->collectRates($request);
00142             }
00143             // sort rates by price
00144             if (method_exists($result, 'sortRatesByPrice')) {
00145                 $result->sortRatesByPrice();
00146             }
00147             $this->getResult()->append($result);
00148         }
00149         return $this;
00150     }

collectRates ( Mage_Shipping_Model_Rate_Request request  ) 

Retrieve all methods for supplied shipping data

Todo:
make it ordered
Parameters:
Mage_Shipping_Model_Shipping_Method_Request $data
Returns:
Mage_Shipping_Model_Shipping

Definition at line 92 of file Shipping.php.

00093     {
00094         if (!$request->getOrig()) {
00095             $request
00096                 ->setCountryId(Mage::getStoreConfig('shipping/origin/country_id', $request->getStore()))
00097                 ->setRegionId(Mage::getStoreConfig('shipping/origin/region_id', $request->getStore()))
00098                 ->setCity(Mage::getStoreConfig('shipping/origin/city', $request->getStore()))
00099                 ->setPostcode(Mage::getStoreConfig('shipping/origin/postcode', $request->getStore()));
00100         }
00101 
00102         $limitCarrier = $request->getLimitCarrier();
00103         if (!$limitCarrier) {
00104             $carriers = Mage::getStoreConfig('carriers', $request->getStoreId());
00105 
00106             foreach ($carriers as $carrierCode=>$carrierConfig) {
00107                 $this->collectCarrierRates($carrierCode, $request);
00108             }
00109         } else {
00110             if (!is_array($limitCarrier)) {
00111                 $limitCarrier = array($limitCarrier);
00112             }
00113             foreach ($limitCarrier as $carrierCode) {
00114                 $carrierConfig = Mage::getStoreConfig('carriers/'.$carrierCode, $request->getStoreId());
00115                 if (!$carrierConfig) {
00116                     continue;
00117                 }
00118                 $this->collectCarrierRates($carrierCode, $request);
00119             }
00120         }
00121 
00122         return $this;
00123     }

collectRatesByAddress ( Varien_Object address,
limitCarrier = null 
)

Definition at line 152 of file Shipping.php.

00153     {
00154         $request = Mage::getModel('shipping/rate_request');
00155         $request->setDestCountryId($address->getCountryId());
00156         $request->setDestRegionId($address->getRegionId());
00157         $request->setDestPostcode($address->getPostcode());
00158         $request->setPackageValue($address->getBaseSubtotal());
00159         $request->setPackageWeight($address->getWeight());
00160         $request->setFreeMethodWeight($address->getFreeMethodWeight());
00161         $request->setPackageQty($address->getItemQty());
00162         $request->setStoreId(Mage::app()->getStore()->getId());
00163         $request->setWebsiteId(Mage::app()->getStore()->getWebsiteId());
00164         $request->setBaseCurrency(Mage::app()->getStore()->getBaseCurrency());
00165         $request->setPackageCurrency(Mage::app()->getStore()->getCurrentCurrency());
00166 
00167         $request->setLimitCarrier($limitCarrier);
00168 
00169         return $this->collectRates($request);
00170     }

getCarrierByCode ( carrierCode,
storeId = null 
)

Definition at line 172 of file Shipping.php.

00173     {
00174         if (!Mage::getStoreConfigFlag('carriers/'.$carrierCode.'/active', $storeId)) {
00175             return false;
00176         }
00177         $className = Mage::getStoreConfig('carriers/'.$carrierCode.'/model', $storeId);
00178         if (!$className) {
00179             return false;
00180             #Mage::throwException('Invalid carrier: '.$carrierCode);
00181         }
00182         $obj = Mage::getModel($className);
00183         if ($storeId) {
00184             $obj->setStore($storeId);
00185         }
00186         return $obj;
00187     }

getConfig (  ) 

Retrieve configuration model

Returns:
Mage_Shipping_Model_Config

Definition at line 80 of file Shipping.php.

00081     {
00082         return Mage::getSingleton('shipping/config');
00083     }

getResult (  ) 

Get shipping rate result model

Returns:
Mage_Shipping_Model_Rate_Result

Definition at line 50 of file Shipping.php.

00051     {
00052         if (empty($this->_result)) {
00053             $this->_result = Mage::getModel('shipping/rate_result');
00054         }
00055         return $this->_result;
00056     }

resetResult (  ) 

Reset cached result

Definition at line 69 of file Shipping.php.

00070     {
00071         $this->getResult()->reset();
00072         return $this;
00073     }

setOrigData ( data  ) 

Set shipping orig data

Definition at line 61 of file Shipping.php.

00062     {
00063         $this->_orig = $data;
00064     }


Member Data Documentation

$_orig = null [protected]

Definition at line 35 of file Shipping.php.

$_result = null [protected]

Definition at line 42 of file Shipping.php.


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:24:52 2009 for Magento by  doxygen 1.5.8