Public Member Functions | |
reset () | |
setError ($error) | |
getError () | |
append ($result) | |
getAllRates () | |
getRateById ($id) | |
getRatesByCarrier ($carrier) | |
asArray () | |
getCheapestRate () | |
sortRatesByPrice () | |
Protected Attributes | |
$_rates = array() | |
$_error = null |
Definition at line 28 of file Result.php.
append | ( | $ | result | ) |
Add a rate to the result
Mage_Shipping_Model_Rate_Result_Abstract|Mage_Shipping_Model_Rate_Result | $result |
Definition at line 57 of file Result.php.
00058 { 00059 if ($result instanceof Mage_Shipping_Model_Rate_Result_Abstract) { 00060 $this->_rates[] = $result; 00061 } 00062 elseif ($result instanceof Mage_Shipping_Model_Rate_Result) { 00063 $rates = $result->getAllRates(); 00064 foreach ($rates as $rate) { 00065 $this->append($rate); 00066 } 00067 } 00068 return $this; 00069 }
asArray | ( | ) |
Definition at line 103 of file Result.php.
00104 { 00105 $currencyFilter = Mage::app()->getStore()->getPriceFilter(); 00106 $rates = array(); 00107 $allRates = $this->getAllRates(); 00108 foreach ($allRates as $rate) { 00109 $rates[$rate->getCarrier()]['title'] = $rate->getCarrierTitle(); 00110 $rates[$rate->getCarrier()]['methods'][$rate->getMethod()] = array( 00111 'title'=>$rate->getMethodTitle(), 00112 'price'=>$rate->getPrice(), 00113 'price_formatted'=>$currencyFilter->filter($rate->getPrice()), 00114 ); 00115 } 00116 return $rates; 00117 }
getAllRates | ( | ) |
getCheapestRate | ( | ) |
Definition at line 119 of file Result.php.
00120 { 00121 $cheapest = null; 00122 $minPrice = 100000; 00123 foreach ($this->getAllRates() as $rate) { 00124 if (is_numeric($rate->getPrice()) && $rate->getPrice()<$minPrice) { 00125 $cheapest = $rate; 00126 $minPrice = $rate->getPrice(); 00127 } 00128 } 00129 return $cheapest; 00130 }
getError | ( | ) |
getRateById | ( | $ | id | ) |
getRatesByCarrier | ( | $ | carrier | ) |
reset | ( | ) |
Reset result
Definition at line 36 of file Result.php.
00037 { 00038 $this->_rates = array(); 00039 return $this; 00040 }
setError | ( | $ | error | ) |
sortRatesByPrice | ( | ) |
Sort rates by price from min to max
Definition at line 137 of file Result.php.
00138 { 00139 if (!is_array($this->_rates) || !count($this->_rates)) { 00140 return $this; 00141 } 00142 /* @var $rate Mage_Shipping_Model_Rate_Result_Method */ 00143 foreach ($this->_rates as $i => $rate) { 00144 $tmp[$i] = $rate->getPrice(); 00145 } 00146 00147 natsort($tmp); 00148 00149 foreach ($tmp as $i => $price) { 00150 $result[] = $this->_rates[$i]; 00151 } 00152 00153 $this->reset(); 00154 $this->_rates = $result; 00155 return $this; 00156 }
$_error = null [protected] |
Definition at line 31 of file Result.php.
$_rates = array() [protected] |
Definition at line 30 of file Result.php.