Public Member Functions | |
__construct () | |
collectRates (Mage_Shipping_Model_Rate_Request $request) | |
getRate (Mage_Shipping_Model_Rate_Request $request) | |
getCode ($type, $code='') | |
getAllowedMethods () | |
Protected Attributes | |
$_code = 'tablerate' | |
$_default_condition_name = 'package_weight' | |
$_conditionNames = array() |
Definition at line 28 of file Tablerate.php.
__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 Mage_Shipping_Model_Carrier_Abstract.
Definition at line 38 of file Tablerate.php.
00039 { 00040 parent::__construct(); 00041 foreach ($this->getCode('condition_name') as $k=>$v) { 00042 $this->_conditionNames[] = $k; 00043 } 00044 }
collectRates | ( | Mage_Shipping_Model_Rate_Request $ | request | ) |
Enter description here...
Mage_Shipping_Model_Rate_Request | $data |
Reimplemented from Mage_Shipping_Model_Carrier_Abstract.
Definition at line 52 of file Tablerate.php.
00053 { 00054 if (!$this->getConfigFlag('active')) { 00055 return false; 00056 } 00057 00058 if (!$request->getConditionName()) { 00059 $request->setConditionName($this->getConfigData('condition_name') ? $this->getConfigData('condition_name') : $this->_default_condition_name); 00060 } 00061 00062 $result = Mage::getModel('shipping/rate_result'); 00063 $rate = $this->getRate($request); 00064 if (!empty($rate) && $rate['price'] >= 0) { 00065 $method = Mage::getModel('shipping/rate_result_method'); 00066 00067 $method->setCarrier('tablerate'); 00068 $method->setCarrierTitle($this->getConfigData('title')); 00069 00070 $method->setMethod('bestway'); 00071 $method->setMethodTitle($this->getConfigData('name')); 00072 00073 $shippingPrice = $this->getFinalPriceWithHandlingFee($rate['price']); 00074 00075 $method->setPrice($shippingPrice); 00076 $method->setCost($rate['cost']); 00077 00078 $result->append($method); 00079 } 00080 00081 return $result; 00082 }
getAllowedMethods | ( | ) |
Get allowed shipping methods
Implements Mage_Shipping_Model_Carrier_Interface.
Definition at line 127 of file Tablerate.php.
00128 { 00129 return array('bestway'=>$this->getConfigData('name')); 00130 }
getCode | ( | $ | type, | |
$ | code = '' | |||
) |
Definition at line 89 of file Tablerate.php.
00090 { 00091 $codes = array( 00092 00093 'condition_name'=>array( 00094 'package_weight' => Mage::helper('shipping')->__('Weight vs. Destination'), 00095 'package_value' => Mage::helper('shipping')->__('Price vs. Destination'), 00096 'package_qty' => Mage::helper('shipping')->__('# of Items vs. Destination'), 00097 ), 00098 00099 'condition_name_short'=>array( 00100 'package_weight' => Mage::helper('shipping')->__('Weight (and above)'), 00101 'package_value' => Mage::helper('shipping')->__('Order Subtotal (and above)'), 00102 'package_qty' => Mage::helper('shipping')->__('# of Items (and above)'), 00103 ), 00104 00105 ); 00106 00107 if (!isset($codes[$type])) { 00108 throw Mage::exception('Mage_Shipping', Mage::helper('shipping')->__('Invalid Table Rate code type: %s', $type)); 00109 } 00110 00111 if (''===$code) { 00112 return $codes[$type]; 00113 } 00114 00115 if (!isset($codes[$type][$code])) { 00116 throw Mage::exception('Mage_Shipping', Mage::helper('shipping')->__('Invalid Table Rate code for type %s: %s', $type, $code)); 00117 } 00118 00119 return $codes[$type][$code]; 00120 }
getRate | ( | Mage_Shipping_Model_Rate_Request $ | request | ) |
Definition at line 84 of file Tablerate.php.
00085 { 00086 return Mage::getResourceModel('shipping/carrier_tablerate')->getRate($request); 00087 }
$_code = 'tablerate' [protected] |
Reimplemented from Mage_Shipping_Model_Carrier_Abstract.
Definition at line 33 of file Tablerate.php.
$_conditionNames = array() [protected] |
Definition at line 36 of file Tablerate.php.
$_default_condition_name = 'package_weight' [protected] |
Definition at line 34 of file Tablerate.php.