PDF Invoice Address Formatting

http://www.ahawks.com/magento/pdf-invoice-address-formatting/

 

UPDATE: I realized since the values are stored in the core_config_data table in the database then it must be in the configuration somewhere, and indeed it is. It is located under System > Configuration > Customers > Customer Configuration > Address Templates. So instead of editing the value in the database you can edit the value in the admin configuration.


Magento displays the customer’s address in several locations throughout the site including the admin, frontend, PDFs, and emails. However the formatting for all of the address is not always exactly the same.

 

In the admin under Sales > Orders > View the address appears in the following format:

1
2
3
4
5
Aaron Hawks
Address Line 1
City, State, Zip
Country
T: telephone

but in the Invoice PDF under Sales > Invoices > View > Print the address appears in the following format:

1
2
3
4
Aaron Hawks
Address Line 1 City, State, Zip
Country
T: telephone

This topic has been discussed here Invoice Address & PDF Invoice Address Format Not Matching! and here How do I alter format of Shipping Address?

But only one solution posted was posted. The solution posted included adding a row to the directory_country_format table.

The default templates for the address is stored in_app/code/core/Mage/Customer/etc/config.xml_ but after updating it and clearing magento’s cache nothing happens. That’s because the value is stored in the DB in_core_config_data_

1
2
3
4
customer/address_templates/text
customer/address_templates/oneline
customer/address_templates/html
customer/address_templates/pdf

The following is the format for the address in PDFs. The pipe | is used to make a new line so to add a new line after the address line 1 add a pipe directly after { {var street1}}.

{ {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}}| { {depend telephone}}T: { {var telephone}}{ {/depend}}| { {depend fax}} F: { {var fax}}{ {/depend}}|

坚持原创技术分享,您的支持将鼓励我继续创作!