How to generate/pull a report from Appointments+ data

We are hoping to be able to reach out to customers around the anniversary of their appointment with us. Is there a way to pull a report from the booking data? We use Google Calendar to help track and double check bookings so if there is something that direction we are open to it! We currently use the follow up email code and it's been great! I'm not sure if having a second version of that added but based on days rather than hours might work. Here is the link to what we are using https://premium.wpmudev.org/forums/topic/follow-up-email-after-appt-completed.

Details about us: We use the app for birthday party bookings. We would like to send an email a month prior to the anniversary of their previous booking date.

Thanks so much!
Suzy B

  • Suzy

    I've implemented this on our test site and it's not generating the email. I've got management to agree to the first version which is obviously much easier to test. I booked a party for August 3, 2015 12:00 pm hoping it would kick out the 11 month reminder on or around Sept 3rd. But nothing happened. I got the confirmation, reminder and the immediate follow up email ( that goes out 24 hours after). Nothing was in the settings log other than the three emails I listed.

    Am I testing it wrong? Possible the I need a bigger window for there reminder to go out? Any suggestions are welcome! I've granted access to our test site.

  • Nithin

    Hi Suzy,

    Hope you are doing good today. :slight_smile:

    Did the plugin had edits other than this code snippets? Was there any other customization done to the plugin? I was able to notice that the snippet is quite old, and the edits provided by Kasia might not work as expected, as the plugin had been rewritten since April, and chances are that the code won't function as expected. Is it possible to update the plugin to the latest version? So that I could ping our coding experts to give a look regarding this one.

    Please do let us know whether this is possible, so that we could give a closer look. Have a nice day. :slight_smile:

    Kind Regards,
    Nithin

  • Suzy

    As I've mentioned previously (I should start putting it in every posting) we cannot update our app due to the fact that bookings were not removing the time slot from other same time providers. Until that is fixed (and I've been told there is no ETA) we cannot update.

    The code Jude had originally done for us was modified a very little bit. So the code she was basing her's off is a little different. The code snippet he did for us ages ago still works. I am running on test on Kasia's code by just changing the things Jude had changed.

    Here is Jude's altered code (from what Kasia linked above):

    add_filter( 'app_message_headers', 'app_custom_header' );function app_custom_header() { $admin_email = 'birthdays@kidsclub4fun.com'; $blogname = wp_specialchars_decode(get_option('blogname'), ENT_QUOTES); $content_type = apply_filters('app-emails-content_type', 'text/plain'); if (!(defined('APP_EMAIL_DROP_LEGACY_HEADERS') && APP_EMAIL_DROP_LEGACY_HEADERS)) { $message_headers = "MIME-Version: 1.0\n" . "From: {$blogname}" . " <{$admin_email}>\n" . "Reply-To: <" . $blogname . "> <" . $admin_email . ">\n" . "Content-Type: {$content_type}; charset=\"" . get_option('blog_charset') . "\"\n"; } else { $message_headers = "MIME-Version: 1.0\n" . "Reply-To: <" . $blogname . "> <" . $admin_email . ">\n" . "Content-Type: {$content_type}; charset=\"" . get_option('blog_charset') . "\"\n" ; add_filter('wp_mail_from', create_function('', "return '{$admin_email}';")); add_filter('wp_mail_from_name', create_function('', "return '{$blogname}';")); } return $message_headers;
    }
    function follow_up( $value ) {
    global $wpdb, $appointments;

    $a = $appointments;
    // Double check if A+ is active
    if ( !is_object( $a ) )
    return;

    // Follow up time in hours
    $hour = 23;
    // Follow up email subject
    $subject = 'We Would Like to Hear From You!';
    // Follow up email message
    $message = '<center><img src="http://kidsclub4fun.com/newsite/wp-content/uploads/2015/05/kidsclublogo-hi-res.jpg" width="221" height="129"></center>

    Thank you for having your party with Kids Club Fun and Fitness. We would like to see how we did! Below is a link to a survey that will let us know how our performance was.

    Birthday Party Feedback

    Warm Regards,
    Kids Club Fun and Fitness
    (360)-546-5437';

    $results = $wpdb->get_results( "SELECT * FROM " . $a->app_table . " WHERE note NOT LIKE '%Follow up sent%' AND

    status='completed' AND DATE_ADD(start, INTERVAL ".$hour." HOUR) <'" . date ("Y-m-d H:i:s", $a->local_time ). "' " );
    if ( $results ) {
    foreach ( $results as $r ) {
    // Send email
    if ( wp_mail( $r->email, $subject, $message, $a->message_headers() ) ) {
    // Save so that we don't send email again
    $wpdb->update ( $a->app_table,
    array( 'note' => $r->note . ' Follow up sent' ),
    array( 'ID' => $r->ID ),
    array ( '%s' )
    );
    // Log here for better results
    $appointments->log ( sprintf( "Follow up email sent to %s for appointment ID %s" , $r->email , $r->ID ) ) ;
    }
    }
    }
    }
    add_action( 'update_option_app_last_update', 'follow_up' );

    So there are a few different things in this code and I'm trying them out. I'll report back!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.