Skip to content

Commit

Permalink
Display "Free" instead of 0.00$
Browse files Browse the repository at this point in the history
  • Loading branch information
bernattorras committed May 17, 2024
1 parent 0c383dd commit 231d8ec
Showing 1 changed file with 31 additions and 2 deletions.
33 changes: 31 additions & 2 deletions mu-plugins/osi-events-manager-tweaks/osi-events-manager-tweaks.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@
* Author URI: https://wpspecialprojects.wordpress.com/
*/

add_filter('em_event_output_placeholder', 'osi_em_event_output_placeholder', 10, 5);
/**
* Remove the event time zone if the event is all day.
*
* @param string $replace The string to replace.
* @param EM_Event $EM_Event The event object.
* @param string $full_result The full result.
* @param string $target The target.
* @param array $placeholder_atts The placeholder attributes.
*
* @return string
*/
function osi_em_event_output_placeholder( $replace, $EM_Event, $full_result, $target, $placeholder_atts ) {
if ( '#_EVENTTIMEZONE' === $full_result ) {
$event_times = $EM_Event->output('#_EVENTTIMES');
Expand All @@ -16,4 +26,23 @@ function osi_em_event_output_placeholder( $replace, $EM_Event, $full_result, $ta
}
}
return $replace;
}
}
add_filter('em_event_output_placeholder', 'osi_em_event_output_placeholder', 10, 5);

/**
* Display "Free" for events with a price of 0.00.
*
* @param string $formatted_price The formatted price.
* @param string $price The price.
* @param string $currency The currency.
* @param string $format The format.
* @return void
*/
function osi_format_event_manager_price( $formatted_price, $price, $currency, $format ) {
if( 0.00 === (float)$price ) {
$formatted_price = 'Free';
}

return $formatted_price;
}
add_filter('em_get_currency_formatted', 'osi_format_event_manager_price', 10, 4 );

0 comments on commit 231d8ec

Please sign in to comment.