Tribe__Tickets__Tickets::maybe_format_event_cost( float|string $cost, int $post_id )
Formats the cost based on the provider of a ticket of an event.
Contents
Parameters
- $cost
-
(float|string) (Required)
- $post_id
-
(int) (Required)
Return
(string)
Source
File: src/Tribe/Tickets.php
public function maybe_format_event_cost( $cost, $post_id ) {
$tickets = self::get_all_event_tickets( $post_id );
// If $cost isn't a number or there are no tickets, no filter needed.
if ( ! is_numeric( $cost ) || empty( $tickets ) ) {
return $cost;
}
$currency = tribe( 'tickets.commerce.currency' );
// We will convert to the format of the first ticket's provider class.
return $currency->get_formatted_currency( $cost, null, $tickets[0]->provider_class );
}