Support

Home Forums Event Espresso Premium EE4: Array instead of Span with espresso_event_status()

EE4: Array instead of Span with espresso_event_status()

Posted: August 14, 2014 at 5:51 pm


James Kramer

August 14, 2014 at 5:51 pm

I’m trying to programmatically change a “Buy Tickets” button to “Sold Out”. I don’t want to use the Span that get’s outputted from espresso_event_status() function. Is there a similar function or value I can use in PHP to check against whether the event is Sold Out, Inactive or Expired?


Josh

  • Support Staff

August 18, 2014 at 6:32 pm

Hi James,

If this is something you’re adding to an event post, or a loop of event posts, the following will return the event status with no span tags:

function espresso_clean_event_status() {
    global $post;
    $EVT_ID = $post->ID;
    $event = EEH_Event_View::get_event( $EVT_ID );
    $status = $event instanceof EE_Event ? $event->pretty_active_status( FALSE ) : 'inactive';
    $status_sans_tags = wp_strip_all_tags($status);
    return $status_sans_tags;
}


James Kramer

August 19, 2014 at 10:17 am

Thank you, Sir. That worked perfectly.

Along the same question. Is there a way to get just the ticket amount and not the name of the ticket or the HTML tags? I need to display the ticket price like “$45”. Thanks!


Sidney Harrell

August 19, 2014 at 1:30 pm

Once you have the EE_Event object, you’ll need to grab the tickets associated with it: http://code.eventespresso.com/classes/EE_Event.html#method_tickets. Then on each EE_Ticket, you would need to grab it’s base price or all it’s prices http://code.eventespresso.com/classes/EE_Ticket.html#method_base_price. Once you have the EE_Price, you could get the pretty price or the price without the currency symbol http://code.eventespresso.com/classes/EE_Price.html#method_pretty_price


James Kramer

August 19, 2014 at 5:39 pm

Sounds good! Can you give me an example of how I would use?


Josh

  • Support Staff

August 21, 2014 at 3:04 pm

Hi James,

The example I showed you earlier should be sufficient. If it’s not, can you work with a developer on your team on this?

The support post ‘EE4: Array instead of Span with espresso_event_status()’ 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.

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3

Documentation for Event Espresso 4

Status: closed

Updated by  Josh 5 years ago ago

Topic Tags

Notifications

This topic is: not resolved
Do NOT follow this link or you will be banned from the site!