I am trying to rewrite this method. I was following this https://stackoverflow.com/questions/9783185/getaddresseshtmlselect-change-magento. But unseccessfully.
code:
<blocks> <checkout> <rewrite> <onepage_billing>Namespace_Module_Block_Onepage_Billing</onepage_billing> </rewrite> <rewrite> <onepage_shipping>Namespace_Module_Block_Onepage_Shipping</onepage_shipping> </rewrite> </checkout> </blocks>
and shipping(billing) class:
<?php /** * */ class Namespace_Module_Block_Onepage_Shipping extends Mage_Checkout_Block_Onepage_Shipping { public function getAddressesHtmlSelect($ type) { if ($ this->isCustomerLoggedIn()) { $ options = array(); foreach ($ this->getCustomer()->getAddresses() as $ address) { $ options[] = array( 'value' => $ address->getId(), 'label' => $ address->format('oneline') ); } $ addressId = $ this->getAddress()->getCustomerAddressId(); if (empty($ addressId)) { if ($ type=='billing') { $ address = $ this->getCustomer()->getPrimaryBillingAddress(); } else { $ address = $ this->getCustomer()->getPrimaryShippingAddress(); } if ($ address) { $ addressId = $ address->getId(); } } if ($ type === 'shipping') { # code... $ addressId = 5; } $ select = $ this->getLayout()->createBlock('core/html_select') ->setName($ type.'_address_id') ->setId($ type.'-address-select') ->setClass('address-select') ->setExtraParams('onchange="'.$ type.'.newAddress(!this.value)"') ->setValue($ addressId) ->setOptions($ options); $ select->addOption('', Mage::helper('checkout')->__('New Address')); return $ select->getHtml(); } return ''; } } ?>
What I’am doing wrong? Tnx