magento - getAddressesHtmlSelect() 更改 - Magento

标签 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();

最佳答案

寻找magento block 重写。
您需要重写 Mage_Checkout_Block_Onepage_BillingMage_Checkout_Block_Onepage_Shipping
只需在自定义模块中重写此 block 并为 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();

关于magento - getAddressesHtmlSelect() 更改 - Magento,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9783185/

相关文章:

php - Magento - PayPal 未重定向到移动网站

magento - 在现有 Magento 观察者之前触发自定义观察者

php - 调用未定义函数 simplexml_load_string()

magento - SQL 错误 'core_resource' 已经存在

magento - 在 Magento 1.7 中添加自定义注册属性

javascript - 刷新div而不用jquery重新加载页面

php - 你如何在 Magento 中管理你的扩展版本控制

magento - dbModel 读取资源未在 Magento 1.3.2.4 版中实现 Zend_Db_Adapter_Abstract

javascript - 如何在 Magento 中使用像 head.js 或 labjs 这样的 JavaScript 加载器

magento - Mage 注册表项 "_singleton/core/resource"已存在于 magento 中