Mage_Shipping_Model_Carrier_Abstract Class Reference

Inheritance diagram for Mage_Shipping_Model_Carrier_Abstract:

Varien_Object Mage_GoogleCheckout_Model_Shipping Mage_Shipping_Model_Carrier_Flatrate Mage_Shipping_Model_Carrier_Freeshipping Mage_Shipping_Model_Carrier_Pickup Mage_Shipping_Model_Carrier_Tablerate Mage_Usa_Model_Shipping_Carrier_Abstract Mage_Usa_Model_Shipping_Carrier_Dhl Mage_Usa_Model_Shipping_Carrier_Fedex Mage_Usa_Model_Shipping_Carrier_Ups Mage_Usa_Model_Shipping_Carrier_Usps

List of all members.

Public Member Functions

 __construct ()
 getConfigData ($field)
 getConfigFlag ($field)
 collectRates (Mage_Shipping_Model_Rate_Request $request)
 checkAvailableShipCountries (Mage_Shipping_Model_Rate_Request $request)
 proccessAdditionalValidation (Mage_Shipping_Model_Rate_Request $request)
 isActive ()
 isTrackingAvailable ()
 getSortOrder ()
 getMethodPrice ($cost, $method='')
 getFinalPriceWithHandlingFee ($cost)
 convertWeightToLbs ($weight)
 getTotalNumOfBoxes ($weight)
 isStateProvinceRequired ()
 isCityRequired ()
 isZipCodeRequired ()

Public Attributes

const HANDLING_TYPE_PERCENT = 'P'
const HANDLING_TYPE_FIXED = 'F'
const HANDLING_ACTION_PERPACKAGE = 'P'
const HANDLING_ACTION_PERORDER = 'O'

Protected Member Functions

 _updateFreeMethodQuote ($request)

Protected Attributes

 $_code
 $_rates = null
 $_numBoxes = 1


Detailed Description

Definition at line 28 of file Abstract.php.


Constructor & Destructor Documentation

__construct (  ) 

Constructor

By default is looking for first argument as array and assignes it as object attributes This behaviour may change in child classes

Reimplemented from Varien_Object.

Reimplemented in Mage_Shipping_Model_Carrier_Tablerate.

Definition at line 40 of file Abstract.php.

00041     {
00042 
00043     }


Member Function Documentation

_updateFreeMethodQuote ( request  )  [protected]

if we can apply free shipping for all order we should force price to $0.00 for shipping with out sending second request to carrier

if we did not get our free shipping method in response we must use its old price

Reimplemented in Mage_Shipping_Model_Carrier_Freeshipping.

Definition at line 135 of file Abstract.php.

00136     {
00137         if ($request->getFreeMethodWeight()==$request->getPackageWeight()
00138             || !$request->hasFreeMethodWeight()) {
00139             return;
00140         }
00141 
00142         if (!$freeMethod = $this->getConfigData('free_method')) {
00143             return;
00144         }
00145         $freeRateId = false;
00146 
00147         if (is_object($this->_result)) {
00148             foreach ($this->_result->getAllRates() as $i=>$item) {
00149                 if ($item->getMethod()==$freeMethod) {
00150                     $freeRateId = $i;
00151                     break;
00152                 }
00153             }
00154         }
00155 
00156         if ($freeRateId===false) {
00157             return;
00158         }
00159         $price = null;
00160         if ($request->getFreeMethodWeight()>0) {
00161             $this->_setFreeMethodRequest($freeMethod);
00162 
00163             $result = $this->_getQuotes();
00164             if ($result && ($rates = $result->getAllRates()) && count($rates)>0) {
00165                 if ((count($rates) == 1) && ($rates[0] instanceof Mage_Shipping_Model_Rate_Result_Method)) {
00166                     $price = $rates[0]->getPrice();
00167                 }
00168                 if (count($rates) > 1) {
00169                     foreach ($rates as $rate) {
00170                         if ($rate instanceof Mage_Shipping_Model_Rate_Result_Method && $rate->getMethod() == $freeMethod) {
00171                             $price = $rate->getPrice();
00172                         }
00173                     }
00174                 }
00175             }
00176         } else {
00177             /**
00178              * if we can apply free shipping for all order we should force price
00179              * to $0.00 for shipping with out sending second request to carrier
00180              */
00181             $price = 0;
00182         }
00183 
00184         /**
00185          * if we did not get our free shipping method in response we must use its old price
00186          */
00187         if (!is_null($price)) {
00188             $this->_result->getRateById($freeRateId)->setPrice($price);
00189         }
00190     }

checkAvailableShipCountries ( Mage_Shipping_Model_Rate_Request request  ) 

Definition at line 71 of file Abstract.php.

00072     {
00073         $speCountriesAllow = $this->getConfigData('sallowspecific');
00074         /*
00075         * for specific countries, the flag will be 1
00076         */
00077         if($speCountriesAllow && $speCountriesAllow==1){
00078              $showMethod = $this->getConfigData('showmethod');
00079              $availableCountries = array();
00080              if( $this->getConfigData('specificcountry') ) {
00081                 $availableCountries = explode(',',$this->getConfigData('specificcountry'));
00082              }
00083              if ($availableCountries && in_array($request->getDestCountryId(), $availableCountries)) {
00084                  return $this;
00085              } elseif ($showMethod && (!$availableCountries || ($availableCountries && !in_array($request->getDestCountryId(), $availableCountries)))){
00086                    $error = Mage::getModel('shipping/rate_result_error');
00087                    $error->setCarrier($this->_code);
00088                    $error->setCarrierTitle($this->getConfigData('title'));
00089                    $errorMsg = $this->getConfigData('specificerrmsg');
00090                    $error->setErrorMessage($errorMsg?$errorMsg:Mage::helper('shipping')->__('The shipping module is not available for selected delivery country'));
00091                    return $error;
00092              } else {
00093                  /*
00094                 * The admin set not to show the shipping module if the devliery country is not within specific countries
00095                 */
00096                 return false;
00097              }
00098         }
00099         return $this;
00100     }

collectRates ( Mage_Shipping_Model_Rate_Request request  )  [abstract]

convertWeightToLbs ( weight  ) 

Return weight in pounds

Parameters:
integer Weight in someone measure
Returns:
float Weight in pounds

Definition at line 247 of file Abstract.php.

00248     {
00249         return $weight;
00250     }

getConfigData ( field  ) 

Retrieve information from carrier configuration

Parameters:
string $field
Returns:
mixed

Definition at line 51 of file Abstract.php.

00052     {
00053         if (empty($this->_code)) {
00054             return false;
00055         }
00056         $path = 'carriers/'.$this->_code.'/'.$field;
00057         return Mage::getStoreConfig($path, $this->getStore());
00058     }

getConfigFlag ( field  ) 

Definition at line 60 of file Abstract.php.

00061     {
00062         if (empty($this->_code)) {
00063             return false;
00064         }
00065         $path = 'carriers/'.$this->_code.'/'.$field;
00066         return Mage::getStoreConfigFlag($path, $this->getStore());
00067     }

getFinalPriceWithHandlingFee ( cost  ) 

get the handling fee for the shipping + cost

Returns:
final price for shipping emthod

Definition at line 210 of file Abstract.php.

00211     {
00212         $handlingFee = $this->getConfigData('handling_fee');
00213         $finalMethodPrice = 0;
00214         $handlingType = $this->getConfigData('handling_type');
00215         if (!$handlingType) {
00216             $handlingType = self::HANDLING_TYPE_FIXED;
00217         }
00218         $handlingAction = $this->getConfigData('handling_action');
00219         if (!$handlingAction) {
00220             $handlingAction = self::HANDLING_ACTION_PERORDER;
00221         }
00222 
00223         if($handlingAction == self::HANDLING_ACTION_PERPACKAGE)
00224         {
00225             if ($handlingType == self::HANDLING_TYPE_PERCENT) {
00226                 $finalMethodPrice = ($cost + ($cost * $handlingFee/100)) * $this->_numBoxes;
00227             } else {
00228                 $finalMethodPrice = ($cost + $handlingFee) * $this->_numBoxes;
00229             }
00230         } else {
00231             if ($handlingType == self::HANDLING_TYPE_PERCENT) {
00232                 $finalMethodPrice = ($cost * $this->_numBoxes) + ($cost * $this->_numBoxes * $handlingFee/100);
00233             } else {
00234                 $finalMethodPrice = ($cost * $this->_numBoxes) + $handlingFee;
00235             }
00236 
00237         }
00238         return $finalMethodPrice;
00239     }

getMethodPrice ( cost,
method = '' 
)

Definition at line 192 of file Abstract.php.

00193     {
00194         if ($method == $this->getConfigData('free_method') &&
00195             $this->getConfigData('free_shipping_enable') &&
00196             $this->getConfigData('free_shipping_subtotal') <= $this->_rawRequest->getValueWithDiscount())
00197         {
00198             $price = '0.00';
00199         } else {
00200             $price = $this->getFinalPriceWithHandlingFee($cost);
00201         }
00202         return $price;
00203     }

getSortOrder (  ) 

Definition at line 130 of file Abstract.php.

00131     {
00132         return $this->getConfigData('sort_order');
00133     }

getTotalNumOfBoxes ( weight  ) 

set the number of boxes for shipping

Returns:
weight

Definition at line 257 of file Abstract.php.

00258     {
00259         /*
00260         reset num box first before retrieve again
00261         */
00262         $this->_numBoxes = 1;
00263         $weight = $this->convertWeightToLbs($weight);
00264         $maxPackageWeight = $this->getConfigData('max_package_weight');
00265         if($weight > $maxPackageWeight && $maxPackageWeight != 0) {
00266             $this->_numBoxes = ceil($weight/$maxPackageWeight);
00267             $weight = $weight/$this->_numBoxes;
00268         }
00269         return $weight;
00270     }

isActive (  ) 

Definition at line 114 of file Abstract.php.

00115     {
00116         $active = $this->getConfigData('active');
00117         return $active==1 || $active=='true';
00118     }

isCityRequired (  ) 

Reimplemented in Mage_Usa_Model_Shipping_Carrier_Abstract.

Definition at line 277 of file Abstract.php.

00278     {
00279         return false;
00280     }

isStateProvinceRequired (  ) 

Reimplemented in Mage_Usa_Model_Shipping_Carrier_Dhl.

Definition at line 272 of file Abstract.php.

00273     {
00274         return false;
00275     }

isTrackingAvailable (  ) 

Check if carrier has shipping tracking option available

Returns:
boolean

Reimplemented in Mage_Usa_Model_Shipping_Carrier_Abstract.

Definition at line 125 of file Abstract.php.

00126     {
00127         return false;
00128     }

isZipCodeRequired (  ) 

Reimplemented in Mage_Usa_Model_Shipping_Carrier_Abstract.

Definition at line 282 of file Abstract.php.

00283     {
00284         return false;
00285     }

proccessAdditionalValidation ( Mage_Shipping_Model_Rate_Request request  ) 

Processing additional validation to check is carrier applicable.

Parameters:
Mage_Shipping_Model_Rate_Request $request
Returns:
Mage_Shipping_Model_Carrier_Abstract|Mage_Shipping_Model_Rate_Result_Error|boolean

Reimplemented in Mage_Usa_Model_Shipping_Carrier_Abstract.

Definition at line 109 of file Abstract.php.

00110     {
00111         return $this;
00112     }


Member Data Documentation

$_code [protected]

$_numBoxes = 1 [protected]

Definition at line 32 of file Abstract.php.

$_rates = null [protected]

Definition at line 31 of file Abstract.php.

Definition at line 38 of file Abstract.php.

Definition at line 37 of file Abstract.php.

const HANDLING_TYPE_FIXED = 'F'

Definition at line 35 of file Abstract.php.

const HANDLING_TYPE_PERCENT = 'P'

Definition at line 34 of file Abstract.php.


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

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