【问题标题】:Where to find the select html tag for countries on the checkout page in Magento 1.8在 Magento 1.8 的结帐页面上哪里可以找到国家/地区的选择 html 标记
【发布时间】:2014-05-12 22:33:11
【问题描述】:

我在哪里可以在结帐页面上的国家/地区的 html select 标记?

<div class="field form-group">
       <label for="billing:country_id" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
       <div class="input-box">
          <?php echo $this->getCountryHtmlSelect('billing') ?>
       </div>
</div>

有了这个$this-&gt;getCountryHtmlSelect('billing'),它返回下面的html select标签,

<select name="billing[country_id]" id="billing:country_id" class="validate-select" title="Country" >
<option value="" > </option>
<option value="AF" >Afghanistan</option><option value="AL" >Albania</option>
<option value="DZ" >Algeria</option>
...

但我需要在select 标签中添加一个类名

class="form-control validate-select"

但是我在哪里可以找到这个select 标签?

【问题讨论】:

    标签: magento magento-1.8


    【解决方案1】:

    要在选择中添加新类...您需要执行以下步骤:

    步骤:复制app\code\core\Mage\Checkout\Block\Onepage\Abstract.phpapp\code\local\Mage\Checkout\Block\Onepage\Abstract.php

    在这里你可以找到函数getCountryHtmlSelect($type)

    代码

        $select = $this->getLayout()->createBlock('core/html_select')
                    ->setName($type.'[country_id]')
                    ->setId($type.':country_id')
                    ->setTitle(Mage::helper('checkout')->__('Country'))
                    ->setClass('validate-select')
            ->setValue($countryId)
    

    更改为,我添加了一个新类mynewclass..

    if($type=='billing')
    {
    $select = $this->getLayout()->createBlock('core/html_select')
                ->setName($type.'[country_id]')
                ->setId($type.':country_id')
                ->setTitle(Mage::helper('checkout')->__('Country'))
                ->setClass('validate-select mynewclass')
                ->setValue($countryId)
    }else{
    $select = $this->getLayout()->createBlock('core/html_select')
                ->setName($type.'[country_id]')
                ->setId($type.':country_id')
                ->setTitle(Mage::helper('checkout')->__('Country'))
                ->setClass('validate-select')
                ->setValue($countryId)
    }
    

    【讨论】:

    • 有没有办法为国家/地区的onchange添加JavaScript函数
    猜你喜欢
    • 2015-09-13
    • 1970-01-01
    • 2018-08-08
    • 1970-01-01
    • 2014-03-29
    • 2018-09-28
    • 1970-01-01
    • 2016-01-01
    • 2017-04-27
    相关资源
    最近更新 更多