If a client cancels an appointment on the front end page,

If a client cancels an appointment on the front end page, by clicking cancel, the admin gets a notification, but the client doesn't get an email confirmation of the cancelation.

How can we send an email confirmation of the cancellation to the admin as well as the client?

  • Vaughan

    hiya

    this currently isn't possible without some custom coding, however i will add this to the features list for a future update.

    in the mean time you can add the code like this. (i haven't tested it though)

    in appointments.php

    find in function send_notification

    if ( $cancel ) {
    				$subject = __('An appointment has been cancelled', 'appointments');
    				$body = sprintf( __('Appointment with ID %s has been cancelled by the client. You can see it clicking this link: %s','appointments'), $app_id, admin_url("admin.php?page=appointments&type=removed") );
    			}
    			else {
    				$subject = __('An appointment requires your confirmation', 'appointments');
    				$body = sprintf( __('The new appointment has an ID %s and you can edit it clicking this link: %s','appointments'), $app_id, admin_url("admin.php?page=appointments&type=pending") );
    			}
    			$body = apply_filters( 'app_notification_message', $body, $r, $app_id );
    
    			$mail_result = wp_mail(
    					$admin_email,
    					$subject,
    					$body,
    					$this->message_headers( )
    				);
    
    			if ( $mail_result && isset( $this->options["log_emails"] ) && 'yes' == $this->options["log_emails"] ) {
    				$this->log( sprintf( __('Notification message sent to %s for appointment ID:%s','appointments'), $admin_email, $app_id ) );
    				do_action( 'app_notification_sent', $body, $r, $app_id );
    			}

    then add this right after

    if ( $cancel ) {
    				$subject = 'Your appointment has been cancelled';
    				$body = sprintf('Appointment with ID %s has been cancelled', $app_id );
                    $body = apply_filters( 'app_notification_message', $body, $r, $app_id );
    
                    $mail_result = wp_mail(
                            $r->email,
                            $subject,
                            $body,
                            $this->message_headers( )
                        );
    
                    if ( $mail_result && isset( $this->options["log_emails"] ) && 'yes' == $this->options["log_emails"] ) {
                        $this->log( sprintf( __('Notification message sent to %s for appointment ID:%s','appointments'), $r->email, $app_id ) );
                        do_action( 'app_notification_sent', $body, $r, $app_id );
                    }
                }

    hope this helps

  • Vaughan

    hiya

    sorry for the delay.

    I'm not sure if this will work or not.

    if ( $cancel ) {
    				$subject = 'Your appointment has been cancelled';
    				$body = sprintf("Appointment with ID %s has been cancelled\n\n
                                    Client Details:\n\n %s \n %s \n %s", $app_id, $r->name, $r->address, $r->city);
                    $body = apply_filters( 'app_notification_message', $body, $r, $app_id );
    
                    $mail_result = wp_mail(
                            $r->email,
                            $subject,
                            $body,
                            $this->message_headers( )
                        );
    
                    if ( $mail_result && isset( $this->options["log_emails"] ) && 'yes' == $this->options["log_emails"] ) {
                        $this->log( sprintf( __('Notification message sent to %s for appointment ID:%s','appointments'), $r->email, $app_id ) );
                        do_action( 'app_notification_sent', $body, $r, $app_id );
                    }
                }

    hope this helps

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.