How to add currency to the structured data for The Events Calendar

The Events Calendar plugin (by Modern Tribe) doesn’t include the currency in the structured data it outputs, because all that is captured when adding a price to an event is the symbol:

If all your events have the same currency though, you can use a filter in your child theme’s functions.php or a small functional plugin to add the priceCurrency piece of the Event schema:

 

function tecs_add_currency( $data ) {
    if ( is_object( $data->offers ) ) {
        $data->offers->priceCurrency = 'CAD';
    }
    return $data;
}
add_filter( 'tribe_json_ld_event_object', 'tecs_add_currency' );

 

Replacing CAD with your local currency. Now events will be parsed with the currency when indexed by Google!

Of course this meta will also be used in the output for The Events Calendar Shortcode 🙂