Hello,
I created a custom field fot the events. I can display it on the event detail page with this code :
<?php
$acompte = get_field('acompte');
$formatted_price_acompte = eo_format_price( $acompte, true ); //Format price with currency
echo $formatted_price_acompte;
?>
Now I want to display it in the mail sent to my users after a booking. For this I’m editing this action :
//Only send receipt on offline payment.
add_action( 'eventorganiser_pre_gateway_booking_offline', 'email_booking_receipt' );
//Uncomment the line below if necessary
//add_action( 'eventorganiser_pre_gateway_booking_free', 'email_booking_receipt' );
function email_booking_receipt( $booking_id ){
//If you need it:
$post_id = (int) eo_get_booking_meta( $booking_id, 'event_id' );
$occurrence_id = (int) eo_get_booking_meta( $booking_id, 'occurrence_id' );
$booking_amount = (int) eo_get_booking_meta( $booking_id, 'booking_amount' );
$user_id = (int) eo_get_booking_meta( $booking_id, 'bookee' );
//You may want to check that $booking_amount > 0 before proceeding
/* Set the recipients email */
$bookee_email = eo_get_booking_meta( $booking_id, 'bookee_email' );
/* Set email template - optional */
$template = eventorganiser_pro_get_option( 'email_template' );
/* Set headers - optional */
$from_name = get_bloginfo( 'name' );
$from_email = get_option( 'admin_email' );
$headers = "From: " . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>\r\n";
$headers .= "Reply-To: ". $from_email . "\r\n";
/* Set message */
$message = "My message
";
$message = eventorganiser_email_template_tags( $message , $booking_id, $template );//Parses the email tags
/* Set subject */
$subject = 'Votre inscription est en attente de validation';
/* Send message */
eventorganiser_mail( $bookee_email, $subject, $message, $headers, array(), $template );
}
Could you please tell me how to achieve it ?

Nicolas Massart
get_field()
is a function in ACF (docs can be found here). The second argument allows you to pass the event (post) ID – $post_id
in the above snippet.

Stephen Harris
Thank you. I’m not an expert in php, I cannot get it working, could please tell me exactly what code to use and where in the snippet posted above ?

Nicolas Massart
/* Set message */
$acompte = get_field( 'acompte', $post_id );
$formatted_price_acompte = eo_format_price( $acompte, true )
$message = "This the custom field value: " . $formatted_price_acompte;

Stephen Harris