How to Show a Ticket with a Price of Zero as Free

In this post we’ll learn how to show tickets that have a cost of zero as free and remove the dollar amount showing from the pricing option (ticket) selector. Lets begin by taking a look at a screenshot below of the default configuration of the price of a free (0.00) ticket:

ticket-selector-zero-pricing

We can see in the screenshot that the default configuration for a free ticket has a pricing of zero (shown as 0.00). Now, to show the price as “free” instead of “0.00.” you can will change this default configuration on your own site with a filter.

function convert_zero_to_free( $amount, $return_raw ) {

    if ( ! $return_raw || ! is_admin() ) {

     $amount = $amount == 0 ?  __( 'free', 'event_espresso' ) : $amount; 

    }
    return $amount;
}
add_filter( 'FHEE__EEH_Template__format_currency__amount', 'convert_zero_to_free', 10, 2 );

There are a couple ways to add the filter above to your site. The first is to add the code to your theme’s functions.php file. However, this edit may be lost if you update your theme and it removes and replaces the functions.php file. We strongly recommend a safer method of applying this filter to your site to protect it from being overwritten by theme updates by creating a custom/site-specific plugin.

Once this filter is in place, go to any events on your site that has a 0.00 priced ticket and you’ll see that the pricing has been transformed from 0.00 to free:

ticket-selector-free-pricing


Need more help?

  • Browse or search for more information on this topic in our support forums. Customers with an active support license can open a support topic and get help from Event Espresso staff.
  • Have an emergency? Purchase a support token and get expedited one-on-one help!
  • Go back to documentation for Event Espresso
Event Espresso