Mage_Shipping_Model_Carrier_Flatrate Class Reference

Inheritance diagram for Mage_Shipping_Model_Carrier_Flatrate:

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 Attributes

 $_code = 'flatrate'


Detailed Description

Definition at line 35 of file Flatrate.php.


Member Function Documentation

collectRates ( Mage_Shipping_Model_Rate_Request request  ) 

Enter description here...

Parameters:
Mage_Shipping_Model_Rate_Request $data
Returns:
Mage_Shipping_Model_Rate_Result

Reimplemented from Mage_Shipping_Model_Carrier_Abstract.

Definition at line 48 of file Flatrate.php.

00049     {
00050         if (!$this->getConfigFlag('active')) {
00051             return false;
00052         }
00053 
00054         $freeBoxes = 0;
00055         if ($request->getAllItems()) {
00056             foreach ($request->getAllItems() as $item) {
00057                 if ($item->getFreeShipping() && !$item->getProduct()->isVirtual()) {
00058                     $freeBoxes+=$item->getQty();
00059                 }
00060             }
00061         }
00062         $this->setFreeBoxes($freeBoxes);
00063 
00064         $result = Mage::getModel('shipping/rate_result');
00065         if ($this->getConfigData('type') == 'O') { // per order
00066             $shippingPrice = $this->getConfigData('price');
00067         } elseif ($this->getConfigData('type') == 'I') { // per item
00068             $shippingPrice = ($request->getPackageQty() * $this->getConfigData('price')) - ($this->getFreeBoxes() * $this->getConfigData('price'));
00069         } else {
00070             $shippingPrice = false;
00071         }
00072 
00073         $shippingPrice = $this->getFinalPriceWithHandlingFee($shippingPrice);
00074 
00075         if ($shippingPrice !== false) {
00076             $method = Mage::getModel('shipping/rate_result_method');
00077 
00078             $method->setCarrier('flatrate');
00079             $method->setCarrierTitle($this->getConfigData('title'));
00080 
00081             $method->setMethod('flatrate');
00082             $method->setMethodTitle($this->getConfigData('name'));
00083 
00084             if ($request->getFreeShipping() === true || $request->getPackageQty() == $this->getFreeBoxes()) {
00085                 $shippingPrice = '0.00';
00086             }
00087 
00088 
00089             $method->setPrice($shippingPrice);
00090             $method->setCost($shippingPrice);
00091 
00092             $result->append($method);
00093         }
00094 
00095         return $result;
00096     }

getAllowedMethods (  ) 

Get allowed shipping methods

Returns:
array

Implements Mage_Shipping_Model_Carrier_Interface.

Definition at line 98 of file Flatrate.php.

00099     {
00100         return array('flatrate'=>$this->getConfigData('name'));
00101     }


Member Data Documentation

$_code = 'flatrate' [protected]

Reimplemented from Mage_Shipping_Model_Carrier_Abstract.

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