In a Views view that pulls out order information, I'm trying to put the Shipping and Billing addresses, but the addresses seem to be all joined up, and there's no way to split them into different lines. I'm grabbing a field called Commerce Order: Shipping information and Commerce Order: Billing Information

At the moment it looks like:

Name123 StreetSome RoadSome CitySome CountryPOSTCODE

I want it to look like:

123 Street
Some Road
Some City
Some Country

I'm outputting the result to a CSV export using the Views Data Export module. So I only need it to look readable when I open it with MS Excel.

  • Are there <span> tags wrapping each address part? There normally is, and you could use a simple display: block CSS rule to separate the lines – Clive Aug 30 '12 at 12:59
  • There are no <span> tags. I'm outputting the result of the view to a CSV file so that might be why there's no <span> tags. How could I insert line breaks there to a CSV file? I only need it to look readable when I open it with MS Excel. – Beebee Aug 30 '12 at 13:58

The addresses from the commerce customer panes come from the module addressfield, you need to check which version of it you're using because since this issue, there's independent component support for views, you'll probably need to either apply the patch or use the -dev version for now.

enter image description here


Thanks to this question, and Stan Ascher's answer, I was able to find the correct tokens to use with Rules. I thought I would share it here:

[commerce-order:commerce-customer-billing:commerce-customer-address:locality], [commerce-order:commerce-customer-billing:commerce-customer-address:administrative_area] [commerce-order:commerce-customer-billing:commerce-customer-address:postal_code]

I was looking at this website here - http://www.poi-factory.com/node/7347 which talk about using excel with line breaks.

Perhaps you can try rewriting the output or your display - You'll need the token module installed on your site

Click on the settings field in views to open it's settings

Under rewrite results group, Check the box for "Rewrite the output of this field"

Use these tokens (You can find them and more under "replacement patterns"

[commerce_customer_address-name_line <br>
[commerce_customer_address-thoroughfare] <br>

You may have to experiment around to get exactly what you want, but we have used this method in the past. For US addresses we use:

[commerce_customer_address-name_line] <br>
[commerce_customer_address-thoroughfare] <br>
[commerce_customer_address-locality], [commerce_customer_address-administrative_area],

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.