我希望你們都做得很好,獲取所有美國州下拉列表中的magento註冊
我在magento 1.6.0.1中工作。 我目前的網站只針對美國,所以在註冊頁面不需要國家下拉列表,並且必須在狀態下拉列表中顯示所有美國狀態。
現在我在隱藏字段中設置國家值「US」。
所以,我怎麼可以得到狀態的所有美國狀態下拉列表
我希望你們都做得很好,獲取所有美國州下拉列表中的magento註冊
我在magento 1.6.0.1中工作。 我目前的網站只針對美國,所以在註冊頁面不需要國家下拉列表,並且必須在狀態下拉列表中顯示所有美國狀態。
現在我在隱藏字段中設置國家值「US」。
所以,我怎麼可以得到狀態的所有美國狀態下拉列表
在register.phtml添加這顯示美國的國家:
<div class="field">
<label for="region_id" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
<div class="input-box">
<select id="region_id" name="region_id" title="<?php echo $this->__('State/Province') ?>" class="validate-select">
<option value=""><?php echo $this->__('Please select region, state or province') ?></option>
<?php
$this->setData('country_id','US'); // or 'FR'..., default is 'US'
$regions = $this->getRegionCollection();
foreach($regions as $region)
{
echo "<option value=$region[name]>".$region['name'] . "</option>";
}
?>
</select>
<script type="text/javascript">
//<![CDATA[
$('region_id').setAttribute('defaultValue', "<?php echo $this->getFormData()->getRegionId() ?>");
//]]>
</script>
<input type="text" id="region" name="region" value="<?php echo $this->escapeHtml($this->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" style="display:none;" />
</div>
</div>
</li>
<li class="fields">
<div class="field">
<label for="country" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
<div class="input-box">
<?php echo $this->getCountryHtmlSelect() ?>
</div>
</div>
,並更換底部的javascript:
<script type="text/javascript">
var dataForm = new VarienForm('form-validate', true);
new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>);
</script>
希望這將有助於
從Country and States in Magento:
<script type="text/javascript">
var dataForm = new VarienForm('form-validate', true);
new RegionUpdater('country', 'region', 'region_id', <?php echo $this->helper('directory')->getRegionJson() ?>);
</script>
這對我很有用。
<div class="field">
<label for="region_id" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
<div class="input-box">
<select id="region_id" name="region_id" title="<?php echo $this->__('State/Province') ?>" class="validate-select">
<option value=""><?php echo $this->__('Please select region, state or province') ?></option>
<?php
$regions = Mage::getModel('directory/country')->load('US')->getRegions();
foreach($regions as $region)
{
echo "<option value=$region[name]>".$region['name'] . "</option>";
}
?>
</select>
</div>
</div>