getAddressesHtmlSelect()更改 - Magento

hel*_*efa 3 magento

我一直在尝试编辑getAddressesHtmlSelect()函数(找到code/core/Mage/Checkout/Block/Onepage/abstract.php),以便在创建的dropdpown中首先显示"新地址".

我找到了需要改变的地方,但我无法弄清楚如何做到这一点.有人可以帮忙吗?有问题的代码是:

$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();
Run Code Online (Sandbox Code Playgroud)

Ser*_*gey 5

寻找magento块重写.
您需要重写Mage_Checkout_Block_Onepage_BillingMage_Checkout_Block_Onepage_Shipping
在自定义模块中重写此块,并为getAddressesHtmlSelect函数定义新逻辑

将"新地址"设置为默认值:为您组装工作样本.

array_unshift($options, array('value' => '', 'label'=> Mage::helper('checkout')->__('New Address')));
            $select = $this->getLayout()->createBlock('core/html_select')
                ->setName($type.'_address_id')
                ->setId($type.'-address-select')
                ->setClass('address-select')
                ->setExtraParams('onchange="'.$type.'.newAddress(!this.value)"')
                ->setOptions($options);

            return $select->getHtml();
Run Code Online (Sandbox Code Playgroud)