Magento - 为客户选择邮政编码和地址

Biz*_*oss 3 magento magento-1.4

如何在前端模块中检索一个或多个客户的地址和邮政编码?

谢谢.

Kno*_*ing 6

使用以下代码: - (由@clockworkgeek编写一些不错的代码后编辑)

<?php
$primaryAddress = Mage::getSingleton('customer/session')->getCustomer()
                  ->getPrimaryShippingAddress();
Run Code Online (Sandbox Code Playgroud)

$arrCountryList = Mage::getModel('directory/country_api')->items();
$countryName = '';
foreach($arrCountryList as $_eachCountryList) {
    if ($primaryAddress['country_id'] == $_eachCountryList['country_id']) {
        $countryName = $_eachCountryList['name'];
        break;
    }
}

$countryName = Mage::getModel('directory/country')
               ->loadByCode($primaryAddress->getCountryId())
               ->getName();

echo '<br/>Street Address: '.$primaryAddress->getStreet();
echo '<br/>City: '.$primaryAddress->getCity();
echo '<br/>State/Region: '.$primaryAddress->getRegion();
echo '<br/>Country Code: '.$primaryAddress->getCountryId();
echo '<br/>Country Name: '.$countryName;
echo '<br/>Zip Code: '.$primaryAddress->getPostcode();
?>
Run Code Online (Sandbox Code Playgroud)

我不太确定地区/州的价值.但我想你可以从这里开始.

希望能帮助到你.