_rates)) { $groups = $this->getAddress()->getGroupedAllShippingRates(); $this->_rates = $groups; } return $this->_rates; } /** * Get Address Model * * @return Mage_Sales_Model_Quote_Address */ public function getAddress() { if (empty($this->_address)) { $this->_address = $this->getQuote()->getShippingAddress(); } return $this->_address; } /** * Get Carrier Name * * @param string $carrierCode * @return mixed */ public function getCarrierName($carrierCode) { if ($name = Mage::getStoreConfig('carriers/'.$carrierCode.'/title')) { return $name; } return $carrierCode; } /** * Get Shipping Method * * @return string */ public function getAddressShippingMethod() { return $this->getAddress()->getShippingMethod(); } /** * Get Estimate Country Id * * @return string */ public function getEstimateCountryId() { return $this->getAddress()->getCountryId(); } /** * Get Estimate Postcode * * @return string */ public function getEstimatePostcode() { return $this->getAddress()->getPostcode(); } /** * Get Estimate City * * @return string */ public function getEstimateCity() { return $this->getAddress()->getCity(); } /** * Get Estimate Region Id * * @return mixed */ public function getEstimateRegionId() { return $this->getAddress()->getRegionId(); } /** * Get Estimate Region * * @return string */ public function getEstimateRegion() { return $this->getAddress()->getRegion(); } /** * Show City in Shipping Estimation * * @return bool */ public function getCityActive() { return (bool)Mage::getStoreConfig('carriers/dhl/active') || (bool)Mage::getStoreConfig('carriers/dhlint/active'); } /** * Show State in Shipping Estimation * * @return bool */ public function getStateActive() { return (bool)Mage::getStoreConfig('carriers/dhl/active') || (bool)Mage::getStoreConfig('carriers/tablerate/active') || (bool)Mage::getStoreConfig('carriers/dhlint/active'); } /** * Convert price from default currency to current currency * * @param float $price * @return float */ public function formatPrice($price) { return $this->getQuote()->getStore()->convertPrice($price, true); } /** * Get Shipping Price * * @param float $price * @param bool $flag * @return float */ public function getShippingPrice($price, $flag) { return $this->formatPrice($this->helper('tax')->getShippingPrice( $price, $flag, $this->getAddress(), $this->getQuote()->getCustomerTaxClassId() )); } /** * Obtain available carriers instances * * @return array */ public function getCarriers() { if (null === $this->_carriers) { $this->_carriers = array(); $this->getEstimateRates(); foreach ($this->_rates as $rateGroup) { if (!empty($rateGroup)) { foreach ($rateGroup as $rate) { $this->_carriers[] = $rate->getCarrierInstance(); } } } } return $this->_carriers; } /** * Check if one of carriers require state/province * * @return bool */ public function isStateProvinceRequired() { foreach ($this->getCarriers() as $carrier) { if ($carrier->isStateProvinceRequired()) { return true; } } return false; } /** * Check if one of carriers require city * * @return bool */ public function isCityRequired() { foreach ($this->getCarriers() as $carrier) { if ($carrier->isCityRequired()) { return true; } } return false; } /** * Check if one of carriers require zip code * * @return bool */ public function isZipCodeRequired() { foreach ($this->getCarriers() as $carrier) { if ($carrier->isZipCodeRequired($this->getEstimateCountryId())) { return true; } } return false; } }