Email notifications when changing booking status

WordPress Event Management, Calendars & Registration Forums General Question Email notifications when changing booking status

This topic contains 3 replies, has 2 voices, and was last updated by  Stephen Harris 5 years, 3 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #35691

    Good afternoon, when changing the status of a reservation, an email is not sent to the user “for approval” or “Closed”. How can this be fixed?

    Aleksei Poryvkin
    #35729

    Hi Aleksei,

    By default, notifications are only sent to the bookee when the booking is confirmed. You can hook into any status change, however. Just as an example:

    add_action('eventorganiser_transition_booking_status', function($new_status, $old_status, $booking) {
    
        $message = "Booking changed from $old_status to $new_status";
    
        //This the email template chosen in the plugin settings
        $template = eventorganiser_pro_get_option( 'email_template' );
    
        $from_name = get_bloginfo( 'name' );
        $from_email = eo_get_admin_email( $booking->ID );
        $headers = array(
            'from:' . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>",
            'reply-to:' . $from_email
        );
    
        $bookee_email = eo_get_booking_meta( $booking->ID, 'bookee_email' );
    
        eventorganiser_mail( $bookee_email, "subject", $message, $headers, [], $template );
    }, 10, 3);
    
    Stephen Harris
    #35859

    Good afternoon, thanks, it works. But was it possible to make different messages (e-mail) for different statuses? When changing to status, one letter is approved, and another is closed. And another question, how to translate into Russian the statuses themselves that come in the letter?
    http://joxi.ru/1A5dbX9iDPZDY2

    Aleksei Poryvkin
    #35879

    Hi Aleksei,

    You can use the $old_status and $new_status variables to target a particular transition.

    E.g.

    add_action('eventorganiser_transition_booking_status', function($new_status, $old_status, $booking) {
    
        if ($new_status === 'pending' && $old_status === 'confirmed') {
              //Booking was confirmed, but is now pending
             $message = '...'; //set email message as appropriate
             $subject = '...'; //set email subject as appropriate
        } else if ( $new_status === 'confirmed' ) {
              //Booking was previously not confirmed, but is now confirmed
             $message = '...'; //set email message as appropriate
             $subject = '...'; //set email subject as appropriate
        } else {
           //Otherwise don't send an email
            return;
        }
        //...
    }, 10, 3);
    

    The above allows you to set a different message for bookings which go from confirmed to pending (for whatever reason) or bookings which transition to confirmed (from any status).

    In that way, you can target bookings which go from and to particular statuses, or which go from a particular status, or go to a particular status.

    As you are setting the $message and $subject yourself, you can just write the content in Russian.

    Stephen Harris
Viewing 4 posts - 1 through 4 (of 4 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.