2011-04-04 40 views
6

我想在客戶地址頁面上更改Magento的標準地址格式。我怎樣才能做到這一點?更改Magento Frontend上的標準地址格式

對於那些不知道地址格式的人,這是我們寫地址的方法。例如,法國的英文格式是這樣的:

 
Addressee (Natural person/Organization) 
More detailed description of addressee (optional) 
Housenumber + Streetname 
Postal code + uppercase town 
Country (if other than France) 

爲美國的地址格式是這樣的:

 
Name of address 
Street number and name 
Name of town, State abbreviation + ZIP code 
(typical handwritten format) 

你可以read more at wikipedia。非常感謝。

+0

請更具體一些。什麼是目前的地址格式,你想要什麼樣的地址等 – 2011-04-04 11:05:50

+0

downwoted「不可能回答」類型的問題 – 2011-04-04 11:32:43

+0

我已編輯我的帖子...謝謝 – Bizboss 2011-04-04 12:08:44

回答

11

一般來說地址格式中包含的應用程序/代碼/核心/法師/客戶/ config.xml中尋找一些類似這樣的標記:

...

<default> 
    <customer> 
    <address_formats> 
    <text><![CDATA[{{depend prefix}}{{var prefix}} {{/depend}}{{var firstname}} {{depend middlename}}{{var middlename}} {{/depend}}{{var lastname}}{{depend suffix}} {{var suffix}}{{/depend}} 
{{depend company}}{{var company}}{{/depend}} 
{{if street1}}{{var street1}} 
{{/if}} 
{{depend street2}}{{var street2}}{{/depend}} 
{{depend street3}}{{var street3}}{{/depend}} 
{{depend street4}}{{var street4}}{{/depend}} 
{{if city}}{{var city}}, {{/if}}{{if region}}{{var region}}, {{/if}}{{if postcode}}{{var postcode}}{{/if}} 
{{var country}} 
T: {{var telephone}} 
{{depend fax}}F: {{var fax}}{{/depend}}}]]></text> 
    </address_templates> 
    </customer> 
</default> 

...

+0

非常感謝。就是這樣:) – Bizboss 2011-04-04 13:23:44

+0

如何在新的Magento訂單確認電子郵件中更改此地址格式? – Bizboss 2011-04-04 13:46:29

+1

在address_templates元素中,您將看到文本,html,pdf和oneline的條目。新訂單電子郵件通常使用html格式,因此您可能還需要更新該格式。 – 2011-04-04 14:02:53

28

似乎不再使用config.xml文件(或者只是將缺省值加載到數據庫中)。

轉到:

系統 - >配置 - >客戶 - >客戶配置和向下滾動到地址模板。

在那裏您可以找到與XML文件中相同的代碼。

+0

這隻適用於Magento> 1.4! – Simon 2012-08-28 21:36:27

4

Magento渲染地址,因爲它在magento管理配置中定義。您可以通過更改地址模板來管理地址格式。

進入系統/配置/客戶配置/地址模板/ Html/ 編輯您希望顯示的內容。

同樣,您可以編輯PDF模板以更改地址的pdf視圖。

+0

謝謝,但這只是在新的Magento版本:) – Bizboss 2012-09-25 07:11:58

4

我已創建模塊,用於對全縣定義多個地址格式的基礎:

下面是簡單的方法來創建它。

創建管理模塊插入更新'directory_country_format'表。

在你模塊中重寫Mage_Customer_Block_Address_Renderer_Default類。

覆蓋以下功能

public function getFormat(Mage_Customer_Model_Address_Abstract $address=null) 
{ 
    $countryFormat = is_null($address) ? parent::getFormat($address) :  
    $address->getCountryModel()->getFormat($this->getType()->getCode()); 
    if (is_object($countryFormat)) { 
      $cFormat = $countryFormat->getFormat(); 
     } 

    $format = $countryFormat ? 
    (!empty($cFormat)?$cFormat:$this->getType()->getDefaultFormat()) : 
    $this->getType()->getDefaultFormat(); 
    return $format; 
} 

這裏是我的模塊,幫助你定義客戶國家的地址格式的基礎。

http://magentosolution.com/index.php/2014/08/27/magento-address-formats-base-of-country/