Last active
June 1, 2016 15:48
-
-
Save Pebblo/8973605280c4c5ac9672 to your computer and use it in GitHub Desktop.
Gets the next upcoming datetimes 'sold' values. This can be used within the event description or if you want to use it on another page, pass the event_id parameter to the shortcode. For example [NEXT_UPCOMING_DATETIME_SOLD_VALUE event_id=200] would pull the next upcoming datetime for the event with id 200.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: EE Site Specific Plugin | |
Description: Add custom functions for Event Espresso 4 here. | |
*/ | |
/* Begin Adding Functions Below This Line; Do not include an opening PHP tag as this sample code already includes one! */ | |
function display_next_upcoming_datetime_sold_value( $attributes = array() ) | |
{ | |
//load helpers | |
EE_Registry::instance()->load_helper( 'Event_View' ); | |
if ( empty( $attributes['event_id']) ) { | |
if ( is_single() && is_espresso_event() ) { | |
$event = EEH_Event_View::get_event(); | |
} | |
} else { | |
$event = EEM_Event::instance()->get_one_by_ID( $attributes['event_id'] ); | |
} | |
if( $event instanceof EE_Event) { | |
$datetimes = EEM_Datetime::instance()->get_datetimes_for_event_ordered_by_start_time( $event->ID(), false, false, 1 ); | |
$datetime = end($datetimes); | |
//d($datetime); | |
return $datetime->sold(); | |
} | |
} | |
add_shortcode('NEXT_UPCOMING_DATETIME_SOLD_VALUE','display_next_upcoming_datetime_sold_value'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment