Changing the 'Free' event price to '0' (zero)

Description

When you enter a price or a price range for an event and it is or starts with zero (0), then on the front-end it will show up as 'Free'

If you would rather like to see the number zero instead of 'Free', there are two easy ways to do that.

Option 1 - with a snippet

Copy the below code into your (child) theme's functions.php file (or wherever you usually put custom code).

function tribe_tec_change_free_to_zero ( $translation, $text, $domain ) {

	$custom_text = array(
		'Free' => '0',
	);
 
	// If this text domain starts with "tribe-", "the-events-", or "event-" and we have replacement text
	if( strpos($domain, 'the-events-calendar') === 0 && array_key_exists( $translation, $custom_text ) ) {
		$translation = $custom_text[$translation];
	}
	return $translation;
}
add_filter( 'gettext', 'tribe_tec_change_free_to_zero', 20, 3 );

 

Option 2 - with the 'Say what?' Plugin

The Say what? plugin actually does what the above snippet, but it gives you a nice user interface.

After installing and activating the plugin go to Tools > Text Changes and add a new entry like in this screenshot:

Click on save and you're set.

Plugins

  • The Events Calendar

Notes

  • Originally written in May 2019
  • Tested with The Events Calendar 4.9.2
  • Author: AndrĂ¡s Guseo
  • This is for The Events Calendar plugin. If you need a solution for RSVPs / tickets with Event Tickets or Event Tickets Plus, then this article might be helpful: Removing "Free" from Event Cost Range

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 first of all 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.