Public Member Functions | |
getCustomer () | |
getCheckout () | |
getQuote () | |
isCustomerLoggedIn () | |
getCountryCollection () | |
getRegionCollection () | |
customerHasAddresses () | |
getAddressesHtmlSelect ($type) | |
getCountryHtmlSelect ($type) | |
getRegionHtmlSelect ($type) | |
getCountryOptions () | |
isShow () | |
Protected Attributes | |
$_customer | |
$_checkout | |
$_quote | |
$_countryCollection | |
$_regionCollection | |
$_addressesCollection |
Definition at line 32 of file Abstract.php.
customerHasAddresses | ( | ) |
Definition at line 104 of file Abstract.php.
00105 { 00106 return count($this->getCustomer()->getAddresses()); 00107 }
getAddressesHtmlSelect | ( | $ | type | ) |
Definition at line 110 of file Abstract.php.
00111 { 00112 if ($this->isCustomerLoggedIn()) { 00113 $options = array(); 00114 foreach ($this->getCustomer()->getAddresses() as $address) { 00115 $options[] = array( 00116 'value'=>$address->getId(), 00117 'label'=>$address->format('oneline') 00118 ); 00119 } 00120 00121 $addressId = $this->getAddress()->getId(); 00122 if (empty($addressId)) { 00123 if ($type=='billing') { 00124 $address = $this->getCustomer()->getPrimaryBillingAddress(); 00125 } else { 00126 $address = $this->getCustomer()->getPrimaryShippingAddress(); 00127 } 00128 if ($address) { 00129 $addressId = $address->getId(); 00130 } 00131 } 00132 00133 $select = $this->getLayout()->createBlock('core/html_select') 00134 ->setName($type.'_address_id') 00135 ->setId($type.'-address-select') 00136 ->setClass('address-select') 00137 ->setExtraParams('onchange="'.$type.'.newAddress(!this.value)"') 00138 ->setValue($addressId) 00139 ->setOptions($options); 00140 00141 $select->addOption('', Mage::helper('checkout')->__('New Address')); 00142 00143 return $select->getHtml(); 00144 } 00145 return ''; 00146 }
getCheckout | ( | ) |
Retrieve checkout session model
Definition at line 59 of file Abstract.php.
00060 { 00061 if (empty($this->_checkout)) { 00062 $this->_checkout = Mage::getSingleton('checkout/session'); 00063 } 00064 return $this->_checkout; 00065 }
getCountryCollection | ( | ) |
Definition at line 85 of file Abstract.php.
00086 { 00087 if (!$this->_countryCollection) { 00088 $this->_countryCollection = Mage::getSingleton('directory/country')->getResourceCollection() 00089 ->loadByStore(); 00090 } 00091 return $this->_countryCollection; 00092 }
getCountryHtmlSelect | ( | $ | type | ) |
Definition at line 148 of file Abstract.php.
00149 { 00150 $countryId = $this->getAddress()->getCountryId(); 00151 if (is_null($countryId)) { 00152 $countryId = Mage::getStoreConfig('general/country/default'); 00153 } 00154 $select = $this->getLayout()->createBlock('core/html_select') 00155 ->setName($type.'[country_id]') 00156 ->setId($type.':country_id') 00157 ->setTitle(Mage::helper('checkout')->__('Country')) 00158 ->setClass('validate-select') 00159 ->setValue($countryId) 00160 ->setOptions($this->getCountryOptions()); 00161 if ($type === 'shipping') { 00162 $select->setExtraParams('onchange="shipping.setSameAsBilling(false);"'); 00163 } 00164 00165 return $select->getHtml(); 00166 }
getCountryOptions | ( | ) |
Definition at line 182 of file Abstract.php.
00183 { 00184 $options = false; 00185 $useCache = Mage::app()->useCache('config'); 00186 if ($useCache) { 00187 $cacheId = 'DIRECTORY_COUNTRY_SELECT_STORE_' . Mage::app()->getStore()->getCode(); 00188 $cacheTags = array('config'); 00189 if ($optionsCache = Mage::app()->loadCache($cacheId)) { 00190 $options = unserialize($optionsCache); 00191 } 00192 } 00193 00194 if ($options == false) { 00195 $options = $this->getCountryCollection()->toOptionArray(); 00196 if ($useCache) { 00197 Mage::app()->saveCache(serialize($options), $cacheId, $cacheTags); 00198 } 00199 } 00200 return $options; 00201 }
getCustomer | ( | ) |
Get logged in customer
Definition at line 46 of file Abstract.php.
00047 { 00048 if (empty($this->_customer)) { 00049 $this->_customer = Mage::getSingleton('customer/session')->getCustomer(); 00050 } 00051 return $this->_customer; 00052 }
getQuote | ( | ) |
Retrieve sales quote model
Definition at line 72 of file Abstract.php.
00073 { 00074 if (empty($this->_quote)) { 00075 $this->_quote = $this->getCheckout()->getQuote(); 00076 } 00077 return $this->_quote; 00078 }
getRegionCollection | ( | ) |
Definition at line 94 of file Abstract.php.
00095 { 00096 if (!$this->_regionCollection) { 00097 $this->_regionCollection = Mage::getModel('directory/region')->getResourceCollection() 00098 ->addCountryFilter($this->getAddress()->getCountryId()) 00099 ->load(); 00100 } 00101 return $this->_regionCollection; 00102 }
getRegionHtmlSelect | ( | $ | type | ) |
Definition at line 169 of file Abstract.php.
00170 { 00171 $select = $this->getLayout()->createBlock('core/html_select') 00172 ->setName($type.'[region]') 00173 ->setId($type.':region') 00174 ->setTitle(Mage::helper('checkout')->__('State/Province')) 00175 ->setClass('required-entry validate-state') 00176 ->setValue($this->getAddress()->getRegionId()) 00177 ->setOptions($this->getRegionCollection()->toOptionArray()); 00178 00179 return $select->getHtml(); 00180 }
isCustomerLoggedIn | ( | ) |
Definition at line 80 of file Abstract.php.
00081 { 00082 return Mage::getSingleton('customer/session')->isLoggedIn(); 00083 }
isShow | ( | ) |
Retrieve is allow and show block
Reimplemented in Mage_Checkout_Block_Onepage_Shipping_Method, and Mage_Checkout_Block_Onepage_Shipping.
Definition at line 208 of file Abstract.php.
$_addressesCollection [protected] |
Definition at line 39 of file Abstract.php.
$_checkout [protected] |
Definition at line 35 of file Abstract.php.
$_countryCollection [protected] |
Definition at line 37 of file Abstract.php.
$_customer [protected] |
Definition at line 34 of file Abstract.php.
$_quote [protected] |
Definition at line 36 of file Abstract.php.
$_regionCollection [protected] |
Definition at line 38 of file Abstract.php.