Offline payment email sent even on incomplete status

WordPress Event Management, Calendars & Registration Forums Report A Bug Offline payment email sent even on incomplete status

This topic contains 1 reply, has 2 voices, and was last updated by  Stephen Harris 2 years, 7 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #40277

    Hello,

    I am using the offline payment option to manage the bookings.

    If a user doesn’t complete the payment process, the e-mail ” Offline Payment (Email) Instructions” is sent to the visitor and the booking remains on the “incomplete” status. This situation may lead to an overbooking situation.

    My understanding is that this mail should be sent only once the status is pending.

    BTW : Since it is not mandatory for the office payment, is there a way to easily skip the payment page ?

    Thanks in advance for your help.

    Best regards

    zwazo
    #40284

    Hi,

    It should fire the e-mail after the user has clicked the ‘pay offline’ button (immediately after updating the booking to ‘pending’). In theory, there could be an error in updating the booking status from ‘incomplete’ to ‘pending’, but the email would still be sent; however I cannot see why there would occur.

    If you’re only offering offline payment, then you can skip the payment screen step with:

    add_filter('eventorganiser_booking_skip_payment_options', '__return_true'); 
    

    However, I think doing that will result in the booking remaining ‘incomplete’. You can mark the booking automatically as pending via:

    add_action('eventorganiser_transition_booking_status', function($new_status, $old_status, $booking){
        if($old_status === "new" && $new_status === "incomplete") {
            eo_set_booking_status($booking->ID, 'pending');
            // Note, this will not send the email
        }
    }, 10, 3);
    

    Note that the offline payment instructions are sent when the user indicates they are going to pay offline, so the above won’t automatically send the offline email. For that you would need to to the following instead:

    add_action('eventorganiser_transition_booking_status', function($new_status, $old_status, $booking){
        if($old_status === "new" && $new_status === "incomplete") {
            eo_set_booking_status($booking->ID, 'pending');
    
            if ( eventorganiser_pro_get_option( 'offline_email' ) ) {
    
                // Get email details
                $template     = eventorganiser_pro_get_option( 'email_template' );
                $from_name    = get_bloginfo( 'name' );
                $from_email   = eo_get_admin_email( $booking->ID );
                $bookee_email = eo_get_booking_meta( $booking->ID, 'bookee_email' );
                // Get messgage & subject from the options
                $message = eventorganiser_email_template_tags( eventorganiser_pro_get_option( 'offline_email_message' ), $booking->ID, $template );
                $message = wpautop( $message );
                $subject = eventorganiser_pro_get_option( 'offline_email_subject' );
                $subject = wp_specialchars_decode( $subject, ENT_QUOTES );
    
                //Set headers
                $headers = array(
                    'from:' . stripslashes_deep( html_entity_decode( $from_name, ENT_COMPAT, 'UTF-8' ) ) . " <$from_email>",
                    'reply-to:' . $from_email
                );
    
                eventorganiser_mail( $bookee_email, $subject, $message, $headers, array(), $template );
            }
        }
    }, 10, 3);
    
    Stephen Harris
Viewing 2 posts - 1 through 2 (of 2 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.