Support

Home Forums Event Espresso Premium Address formatting

Address formatting

Posted: May 21, 2015 at 9:15 am


Robert Elding

May 21, 2015 at 9:15 am

I think related to this older post: https://eventespresso.com/topic/formatting-issues/

We’re in the UK and so don’t have States. When I set up a venue, sometimes I get an addition unwanted comma and, worse, sometimes I get the word “Unknown” added to the address.

I’d rather not have the extra comma or the Unknown really… Anyway around this?

Address problem 1

Address problem 2

TIA,
Robert


Robert Elding

May 21, 2015 at 9:29 am

I guess one easy way round this is to remove London from the City field and create a new London “state or province”. But it feels a bit hacky… Would be interested to hear if there’s a better way.

Thanks


Robert Elding

May 21, 2015 at 9:36 am

And that’s not without it’s own display bugs:

annoying comma

Wouldn’t it be easier to remove the comma and let your users add it if they want it?


Lorenzo Orlando Caum

  • Support Staff

May 21, 2015 at 10:46 am

Hi, the venue address formatting can be changed. Here is an example:

https://eventespresso.com/topic/address-still-now-showing-correctly/#post-143031


Lorenzo


Robert Elding

May 22, 2015 at 5:05 am

Hi Lorenzo,

Thanks for the prompt update.

I’ve tried that out but now it’s not showing the “Address line 1” and is still showing the “Unknown” text. Unfortunately I’m not great with PHP and don’t have access to a PHP resource at the moment. If it’s possible to explain what’s going on I might be able to make edits.

Thanks


Lorenzo Orlando Caum

  • Support Staff

May 22, 2015 at 7:11 am

Hi Robert, you can copy the code snippet that was provided into your child theme’s functions.php file or you can create a site specific plugin:

https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/

That will change the venue address for you.

Let us know if you are able to get this working!

Thanks


Lorenzo


Robert Elding

May 22, 2015 at 7:27 am

Hi,

Yeah, that’s what I did – into a site-specific plugin. As I was saying above:

I’ve tried that out but now it’s not showing the “Address line 1? and is still showing the “Unknown” text.

Thanks


Robert Elding

May 22, 2015 at 7:57 am

It’s OK, don’t worry. I managed to make sense of the php in the end. I just changed a few of the parameters if anyone else ever reads this:

function espresso_venue_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) {
    EE_Registry::instance()->load_helper( 'Venue_View' );
    $venue = EEH_Venue_View::get_venue( $VNU_ID );
    if ( $echo ) {
        echo  '<div itemprop="address" itemscope="" itemtype="http://schema.org/PostalAddress">' . 
        '<span itemprop="streetAddress">' . $venue->address() . '</span>' . ', ' . 
        '<span itemprop="streetAddress">' . $venue->address2() . '</span>' . ', ' . 
        '<span itemprop="addressLocality">' . $venue->city() . '</span>' . ', ' . ' ' . 
        '<span itemprop="postalCode">' . $venue->zip() . '</span>' . '</div>';
        return '';
    }
    return EEH_Venue_View::venue_address( $type, $VNU_ID );
}


Lorenzo Orlando Caum

  • Support Staff

May 22, 2015 at 8:47 am

Thanks for sharing Robert! I adjusted the formatting on your support post to make copying and pasting a little easier.


Lorenzo


Lorenzo Orlando Caum

  • Support Staff

September 12, 2015 at 11:33 am

Hi Robert,

We wanted to let you know about an enhancement in the current version of Event Espresso 4 that offers more flexibility for venue addresses.

First, please backup your WordPress site and upgrade to the latest release of Event Espresso 4:

https://eventespresso.com/wiki/ee4-changelog/

Next, there is some sample code in this link:

https://gist.github.com/lorenzocaum/5e2658a1f7e7a9a6b5c0

Here is an explanation of the sample code:

In the older versions of Event Espresso, you could change the formatting for the venue address. However, this would apply to all venue addresses. The new enhancement is more flexible as it allows you to change the formatting for certain countries.

In the example code, we have an entry for United Kingdom which has a country code of GB. Then we have the actual formatting which doesn’t include the province or the country name.

Just below that, we have an entry for Canada which has a country code of CA. In Canada, the zip/postal code appears as the end of the address so the formatting will show it in that order.

Below that is an entry for Germany which has a country code of DE with a specific formatting for the address.

If you have modified the venue address through an existing function, then you may consider switching to the new one mentioned in the link above.

Thanks!


Lorenzo

The support post ‘Address formatting’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso