Created
February 7, 2019 04:22
-
-
Save michael-pratt/e18c87c9e497c08bc3c048813d63cdf8 to your computer and use it in GitHub Desktop.
customize-events-calendar-popup-single-event-php
This file contains hidden or 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 | |
// Define default values to protect against events not having tickets | |
$additional_data = array(); | |
$additional_data['price'] = ""; | |
$additional_data['stock'] = ""; | |
// Get ticket prices and quantity; this works specifically for WooCommerce | |
// tickets only and will need to be changed if you use other types such | |
// as RSVP tickets. | |
if ( class_exists('Tribe__Tickets_Plus__Commerce__WooCommerce__Main') ) | |
{ | |
$tickets_provider = Tribe__Tickets_Plus__Commerce__WooCommerce__Main::get_instance(); | |
$ticket_ids = $tickets_provider->get_tickets_ids( get_the_ID() ); | |
if($ticket_ids) | |
{ | |
// Assumes 1 tickets per event; if that's no true then you'll need to | |
// handle that | |
$additional_data['price'] = " - $" . get_post_meta( $ticket_ids[0] , '_regular_price')[0]; | |
$stock = get_post_meta( $ticket_ids[0] , '_stock')[0]; | |
if($stock == 0) | |
{ | |
$additional_data['stock'] = "Sold out!"; | |
} | |
elseif($stock == 1) | |
{ | |
$additional_data['stock'] = "Only 1 spot left!"; | |
} | |
else | |
{ | |
$additional_data['stock'] = number_format($stock) . " spots remaining"; | |
} | |
} | |
} | |
// All events have a link so this is safe | |
$additional_data['link'] = esc_url( $link ); | |
?> | |
<div id="tribe-events-event-<?php echo esc_attr( $event_id ); ?>" class="<?php tribe_events_event_classes() ?>" data-tribejson='<?php echo esc_attr( tribe_events_template_data( $post, $additional_data ) ); ?>'> | |
<h3 class="tribe-events-month-event-title"><a href="<?php echo esc_url( $link ) ?>" class="url"><?php echo $title ?></a></h3> | |
</div><!-- #tribe-events-event-# --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment