Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/email/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何将国家/地区选择更改为magento一步结账中的输入字段?_Php_Magento_Onestepcheckout - Fatal编程技术网

Php 如何将国家/地区选择更改为magento一步结账中的输入字段?

Php 如何将国家/地区选择更改为magento一步结账中的输入字段?,php,magento,onestepcheckout,Php,Magento,Onestepcheckout,在billing_fields.phtml中有 <?php $billingFields['country_id'] = ' <div class="input-box input-country'.((in_array('country', $formErrors)) ? ' input-error' : '').'"> <label for="billing:country_id">'.$this->__('Country').' <span

在billing_fields.phtml中有

<?php
$billingFields['country_id'] = '
<div class="input-box input-country'.((in_array('country', $formErrors)) ? ' input-error' : '').'">
    <label for="billing:country_id">'.$this->__('Country').' <span class="required">*</span></label><br />
        '.$this->getCountryHtmlSelect('billing').'
</div>';
?>

我只有一个国家,并且带有呈现下拉列表的select标签$this->getCountryHtmlSelect('billing')对用户不友好,因为它没有其他选项。我觉得它具有误导性和过时性。我的问题是:

如何更改上述代码以在简单(不可编辑)输入字段中显示我的默认国家/地区

编辑 我是在得到CountryCollection的提示后想到这个的


前端看起来不错。甚至后端也能识别给定的值。不幸的是,电子邮件没有。那里的田野仍然空无一人


我遗漏了什么,或者如何使此输入合法,以便magento电子邮件接受其值?

我想说,尝试
getCountryCollection
,查看提供给您的是什么数据结构…然后您自己基于此创建输入字段。备选方案:使用JavaScript将select转换为客户端输入元素。我遵循了您的想法,几乎得到了解决方案。谢谢你。知道如何通过最后一个障碍吗?原始select元素有什么
name
属性,其选项发送什么
value
?(查看源代码)是的!你挽救了这一天<代码>值不同。选择使用的国家id。对于输入值,我使用了国家名称。这就是为什么它在订单确认书中丢失的原因。现在我必须弄清楚如何向用户显示不同的值(完整的国家名称而不是国家代码)。我想我现在就自己试试。非常感谢你!只需插入一个具有正确名称和值的附加输入
type=hidden
。(并省略用于显示的其他输入字段的“名称”属性。)
<?php
$countryCollection = $this->getCountryCollection();
foreach($countryCollection as $country) {
    $country_id = $country['country_id'];
    $countryName = Mage::getModel('directory/country')->load($country_id)->getName();
    $billingFields['country_id'] = '
    <div class="input-box input-country'.((in_array('country', $formErrors)) ? ' input-error' : '').'">
        <label for="billing:country_id">'.$this->__('Country').' </label><br />
            <input type="text" name="billing[country_id]" id="billing:country_id" class="input-text" value="'.$countryName.'" style="width: 83%" readonly="readonly" />
    </div>';
}
?>