Magento - Choose a zip code and address for customers (customers)

How can I get the address and zip code of one or more clients in the interface module?

Thank.

+3
source share
1 answer

Use the following code: - (edited after some good codes from @clockworkgeek)

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

$ 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();
?>

/. , .

, .

+6

Source: https://habr.com/ru/post/1781209/


All Articles