Mage_Shipping_Model_Carrier_Freeshipping Class Reference

Inheritance diagram for Mage_Shipping_Model_Carrier_Freeshipping:

Mage_Shipping_Model_Carrier_Abstract Mage_Shipping_Model_Carrier_Interface Varien_Object

List of all members.

Public Member Functions

 collectRates (Mage_Shipping_Model_Rate_Request $request)
 getAllowedMethods ()

Protected Member Functions

 _updateFreeMethodQuote ($request)

Protected Attributes

 $_code = 'freeshipping'


Detailed Description

Definition at line 35 of file Freeshipping.php.


Member Function Documentation

_updateFreeMethodQuote ( request  )  [protected]

Allows free shipping when all product items have free shipping (promotions etc.)

Parameters:
Mage_Shipping_Model_Rate_Request $request
Returns:
void

Reimplemented from Mage_Shipping_Model_Carrier_Abstract.

Definition at line 87 of file Freeshipping.php.

00088     {
00089         $freeShipping = false;
00090         $items = $request->getAllItems();
00091         $c = count($items);
00092         for ($i = 0; $i < $c; $i++) {
00093             if ($items[$i]->getProduct() instanceof Mage_Catalog_Model_Product) {
00094                 if ($items[$i]->getFreeShipping()) {
00095                     $freeShipping = true;
00096                 } else {
00097                     return;
00098                 }
00099             }
00100         }
00101         if ($freeShipping) {
00102             $request->setFreeShipping(true);
00103         }
00104     }

collectRates ( Mage_Shipping_Model_Rate_Request request  ) 

FreeShipping Rates Collector

Parameters:
Mage_Shipping_Model_Rate_Request $request
Returns:
Mage_Shipping_Model_Rate_Result

Reimplemented from Mage_Shipping_Model_Carrier_Abstract.

Definition at line 48 of file Freeshipping.php.

00049     {
00050         if (!$this->getConfigFlag('active')) {
00051             return false;
00052         }
00053 
00054         $result = Mage::getModel('shipping/rate_result');
00055 //      $packageValue = $request->getBaseCurrency()->convert($request->getPackageValueWithDiscount(), $request->getPackageCurrency());
00056         $packageValue = $request->getPackageValueWithDiscount();
00057 
00058         $this->_updateFreeMethodQuote($request);
00059 
00060         $allow = ($request->getFreeShipping())
00061             || ($packageValue >= $this->getConfigData('free_shipping_subtotal'));
00062 
00063         if ($allow) {
00064             $method = Mage::getModel('shipping/rate_result_method');
00065 
00066             $method->setCarrier('freeshipping');
00067             $method->setCarrierTitle($this->getConfigData('title'));
00068 
00069             $method->setMethod('freeshipping');
00070             $method->setMethodTitle($this->getConfigData('name'));
00071 
00072             $method->setPrice('0.00');
00073             $method->setCost('0.00');
00074 
00075             $result->append($method);
00076         }
00077 
00078         return $result;
00079     }

getAllowedMethods (  ) 

Get allowed shipping methods

Returns:
array

Implements Mage_Shipping_Model_Carrier_Interface.

Definition at line 106 of file Freeshipping.php.

00107     {
00108         return array('freeshipping'=>$this->getConfigData('name'));
00109     }


Member Data Documentation

$_code = 'freeshipping' [protected]

Reimplemented from Mage_Shipping_Model_Carrier_Abstract.

Definition at line 40 of file Freeshipping.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