Removing "Free" from Event Cost Range

If your event has RSVPs or free tickets in addition to paid tickets (say the most expensive ticket is $10), then the cost range for that event will show as "Free - $10" by default. In some cases, showing the event as potentially being free might not be ideal.

🔔 Beware: if you have 3 costs, say, [ 'free', $1, $2 ] it will only show $2 - it skips over the whole minimum costs. It would only display $2.

You can remove "Free" from the cost by adding the following snippet to the functions.php file of your child theme:

/**
 * Grabs the cost early in the process and if the cost is 0 or free,
 * replaces the min cost with the max cost so the range doesn't show.
 *
 * Note this means that if you have more than two costs, it will only show the max.
 */
function tribe_not_show_free_or_dash( $cost, $event_id ) {
    // This removes ALL ocurrances of "Free" and ' - ' if cost = 0 or cost contains "Free
    if ( $cost == 0 || false !== stripos( strtolower( $cost ), 'free' ) ) {
        /* var Tribe__Cost_Utils $cost_utils */
        $cost_utils = tribe( 'cost-utils' );
        /* var Tribe__Events__Cost_Utils $tec_cost_utils */
        $tec_cost_utils = tribe( 'tec.cost-utils' );
        $costs = $tec_cost_utils->get_event_costs( $event_id );
        $relevant_costs = array(
            'min' => $cost_utils->get_minimum_cost( $costs ),
            'max' => $cost_utils->get_maximum_cost( $costs ),
        );
        if ( $relevant_costs['min'] == $cost ) {
            $cost = $relevant_costs['max'];
        }
    }
    return $cost;
}
add_filter ( 'tribe_events_cost_unformatted', 'tribe_not_show_free_or_dash', 10, 2 );

Plugins

Event Tickets, Event Tickets Plus

Notes

  • Updated December 2019
  • Tested with Event Tickets 4.10.5 and Event Tickets Plus 4.10.4
  • Author: Stephen

Disclaimer

As with all of our recipes, please note that we share this in the hope it will be useful but without any guarantees or commitments. If you wish to use it, it is your responsibility to test it and adapt it to your needs (or find someone who can do so on your behalf). We are unable to provide further support in relation to this recipe.