Last active
April 17, 2018 12:04
-
-
Save vicskf/e9f4763809d825a2b768fe83a945c2fd to your computer and use it in GitHub Desktop.
Event Tickets > For ticketed events, it filter the event cost to only consider ticket price if on sale.
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 | |
/** | |
* For ticketed events, it filter the event cost to only consider ticket price if on sale. | |
* | |
* From: https://gist.github.com/vicskf/e9f4763809d825a2b768fe83a945c2fd | |
*/ | |
add_filter( 'tribe_get_cost', 'custom_tribe_get_cost', 10, 3 ); | |
function custom_tribe_get_cost ( $cost, $post_id, $with_currency_symbol ) { | |
if ( ! tribe_events_has_tickets( $post_id ) ) { | |
return $cost; | |
} | |
$currency_symbol = ''; | |
if ( $with_currency_symbol ){ | |
$currency_symbol = get_post_meta( $post_id, '_EventCurrencySymbol', true ); | |
} | |
$prices = array(); | |
foreach ( Tribe__Tickets__Tickets::get_all_event_tickets( $post_id ) as $ticket ) { | |
if ( tribe_events_ticket_is_on_sale( $ticket ) ) { | |
if ( !empty( $ticket->price ) ) { | |
$prices[] = $currency_symbol . $ticket->price; | |
} | |
} | |
} | |
$cost = implode( ", ", $prices ); | |
return $cost; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment