Last active
September 6, 2019 20:17
-
-
Save vicskf/0b159c92567266ff95cd35e9477109a2 to your computer and use it in GitHub Desktop.
Eventbrite Tickets: Temporary workaround for Eventbrite cost issue #133823
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 | |
/** | |
* This will enable the cost field for Eventbrite imported events in the admin | |
* Add this code to your active theme's functions.php file | |
* Important Note: No cost will be displayed for Eventbrite events if none is manually set. | |
*/ | |
if ( class_exists( 'Tribe__Events__Tickets__Eventbrite__Main' ) ) { | |
add_filter( 'tribe_events_admin_show_cost_field', '__return_true' ); | |
add_filter( 'tribe_get_cost', 'temp_tribe_get_cost_eventbrite', 30, 3 ); | |
function temp_tribe_get_cost_eventbrite ( $cost, $post_id, $with_currency_symbol ) { | |
$post = get_post( $post_id ); | |
if ( ! is_object( $post ) || ! $post instanceof WP_Post ) { | |
return $cost; | |
} | |
$eventbrite_id = tribe_eb_get_id( $post->ID ); | |
// If this even is not associated with Eventbrite let's do nothing more | |
if ( empty( $eventbrite_id ) ) { | |
return $cost; | |
} | |
// Force to get EventCost | |
$cost = get_post_meta( $post->ID, '_EventCost', true ); | |
$cost_utils = tribe( 'tec.cost-utils' ); | |
$cost = $cost_utils->get_formatted_event_cost( $post_id, $with_currency_symbol ); | |
// Only return cost | |
if ( !empty( $cost ) ) { | |
return $cost; | |
} | |
return false; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment