Support

Home Forums Event Espresso Premium How do I pull the event venue slug from checkout page

How do I pull the event venue slug from checkout page

Posted: February 19, 2017 at 5:53 pm

Viewing 1 reply thread


Kevin Bull

February 19, 2017 at 5:53 pm

I need to make use of the venue slug when I customer registers for an event ( i am currently using an action). What is the simplest way to pull the slug?


Josh

  • Support Staff

February 20, 2017 at 1:04 pm

Hi Kevin,

It kind of depends on the context of the code you’re working with.

So for example, if you’re using the
AHEE__thank_you_page_overview_template__top
action hook, then you’ll have access to the $transaction object.

Then you can do something like this in your code:

function ee_get_venue_thank_you_page($transaction) {
  if ( $transaction instanceof EE_Transaction ) {
    foreach ( $transaction->registrations() as $registration ) {
      if ( $registration instanceof EE_Registration ) {
        $event = $registration->event();
        if ( $event instanceof EE_Event ) {
          $venue = $event->get_first_related('Venue');
          if ( $venue instanceof EE_Venue ) {
           $venue_slug = $venue->get('VNU_identifier');
           echo $venue_slug;
          }
        }
      }
    }  
  }
}
add_action( 'AHEE__thank_you_page_overview_template__top', 
  'ee_get_venue_thank_you_page', 
  10, 
  1 
);

Note that in the above, it’s only echoing out the venue slug.

Viewing 1 reply thread

The support post ‘How do I pull the event venue slug from checkout page’ 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