Need some Help on App+

When a user makes an appointment and pay the invoice, the Service Provider doesn’t receive the payment notification, only the booking confirmation, can we have an extra e-mail for the payment?

  • Predrag Dubajic
    • Support

    Hi Mustafa,

    I’m not sure that I understand this request completely so I would appreciate if you could provide me with some further information.

    When you enable payments in A+ then the appointment is confirmed once the payment is completed and that’s also when the emails is being sent.

    I did some tests on my installation and this was the behavior for me, once I finished with PayPal payment I received admin confirmation email.

    So could you explain a bit more how the current process looks on your end and how you would like to change it?

    Best regards,

    Predrag

  • mustafa
    • Flash Drive

    –> I don’t want to accept payment unless the service provider confirms the appointment. Once the service provider confirms the appointment and slot he will move the status to confirmed and the customer will get an email saying that their appointment is confirmed

    (This will be temporary confirmation) and they can do payment for final confirmation.

    –> Once the user clicks the link in the email it will redirect them to appointments page where the my appointments tab will show confirmed appointment with a pay button.

    –> The user now clicks and pays the amount through paypal and is redirected back to appointments page.

    –> At this moment service provider receives a mail saying that the payment is done and they can change the status now.

    –> Service provider now clicks the link in the mail and changes the status from confirmed to paid which will let the user know that their appointment is finally confirmed. This should let the user know by email.

    –> Now the my appointment tab should show status to be paid.

    Please ask for any further clarification.

  • Adam Czajczyk
    • Support Gorilla

    Hi mustafa

    Thank you for the explanation!

    I’m afraid such workflow is not possible “out of the box”. If appointment is set as paid, plugin will ask customer to pay right away as the payment is the confirmation.

    You could actually hide the payment button (or perhaps even replace it with some message) using CSS or CSS+JS so after selecting and submitting appointment customer wouldn’t be asked to pay. Such an appointment would be set as pending then and left “hanging there” as pending.

    A service provider could then confirm such appointments manually, though that actually means that booking is done. Since it’s manually confirmed plugin will no longer require payment.

    A sort of workaround could be to edit the “Confirmation email Message” on “Appointments -> Settings -> Notifications” page and include some “general” payment link there (something like a “paypal.me” link or similar or a link from a fully custom payment implementation). Then, the service provider would have to set the appointment as confirmed

    As a result:

    – customer would submit booking as “pending”, it wouldn’t be paid

    – service provider would confirm booking

    – confirmation mail would be send, including your “general” payment link

    – customer could do the payment

    The downside of that is that you couldn’t pass the price of an appointment to that link and the payment wouldn’t be in any way “tied” to the booked appointment so you would have to track that manually.

    To overcome those issues you’d need a custom implementation of payment so you could actually include a link to payment that could take e.g. customer’s e-mail, service name and price as parameters – to let you identify payments properly. Or, going a step further, that would actually change the booking workflow entirely. This, however, is a custom development work, I’m afraid.

    Kind regards,

    Adam

  • mustafa
    • Flash Drive

    Hello,

    Below are the things I figured out

    I have already set up a script for pending email to service provider where they will get mail about pending appointment with a link to confirm appointment.

    The next step is that the service provider clicks the link and changes the appointment to confirmed.

    This status change will send a mail to user about confirmation of appointment.

    I have modified the confirmation notification and added a link for payment which is nothing but appointment page.

    When the user clicks this link he will be redirected to appointments page where the status will show confirmed with a pay button.

    Now the user clicks and makes the payment and redirected back to appointments page,

    Till here it goes as I needed.

    The problem arises now.

    1) After redirecting back to appointment page the status is same as confirmed and the pay button is again visible which should not be the case.

    2) There should be mail sent to service provider about payment done. Once this message is received the service provider will change status from confirmed to paid.

    3) After this status change the user should get mail saying that their appointment is finally confirmed.

  • Adam Czajczyk
    • Support Gorilla

    Hi mustafa

    The problem arises now.

    1) After redirecting back to appointment page the status is same as confirmed and the pay button is again visible which should not be the case.

    2) There should be mail sent to service provider about payment done. Once this message is received the service provider will change status from confirmed to paid.

    3) After this status change the user should get mail saying that their appointment is finally confirmed.

    I understand that but that’s actually the part that would need to be custom developed.There’s a couple of things that are different in the plugin “flow”:

    1. The “paid” and “confirmed” statuses are in “different order” if it comes to what they mean.

    The “paid” status may or may not mean that appointment is confirmed (depending on the Auto-confirm” settings). The “confirmed” status is an “ultimate” confirmation – it’s “higher level” status than “paid”.

    If you have “auto-confirm” option set, making payment will automatically confirm appointment.

    This basically means that if your service provider sets appointment to “confirmed” it, well, confirmed. It hasn’t been paid so the button is there but it’s also already “finally confirmed” – not pending, not “waiting” or anything.

    To achieve what you described (that problematic part) you would actually need to have an additional status created in the plugin that would be “between” pending and paid and that would also trigger an e-mail message, for example “Accepted – payment expected” or similar – that would mean that service provider “accepted” the appointment and is now waiting for the payment to come to possibly confirm it finally. So

    – user would submit booking

    – service provider would set its status to “Accepted – payment expected”

    – a notification would be send to customer with a link back to booking page (as you do now in confirmation message), asking to make payment

    – if Auto-confirm is set, such payment would confirm the booking finally; if not, status would be changed to “Paid” so service provider could then manually confirm it.

    This is not doable “out of the box’, I’m afraid. It would require custom development. However, I have just asked our developers if we would be able to help you with this. I’d rather not promise anything at this stage as I’m not really sure if that’s doable and if so – how complex the code would have to be – but if that’s anything we could provide then either I or one of my colleagues will update you here as soon as we get to know more.

    Kind regards,

    Adam

  • Panos
    • SLS

    Hey mustafa ,

    In case you need to use a new status as Adam described, you can use the following snippet :

    function wpmudev_app_statuses_filter( $statuses ) {
    $statuses['accepted'] = "Accepted - payment expected";
    return $statuses;
    }

    add_filter( 'app_statuses', 'wpmudev_app_statuses_filter', 20 );
    add_filter( 'appointments_list_types', 'wpmudev_app_statuses_filter', 20 );

    You can additionally use the following in order to list the appointments of the accepted status in the admin page:

    // Show the Accepted status tab in admin page
    add_action( 'admin_footer', function(){

    if ( ! function_exists( 'get_current_screen' ) || 'toplevel_page_appointments' != get_current_screen()->id ) {
    return;
    }

    $url = add_query_arg(
    array(
    'page' => 'appointments',
    'type' => 'accepted'
    ),
    admin_url( 'admin.php' )
    );

    ?>
    <script type="text/javascript">
    ($=>{
    $(document).ready(function(){

    const
    status_list_url = "<?php echo $url; ?>",
    accepted_status_list_item = $( '<li />' ),
    accepted_status_list_link = $( '<a />', { 'href' : status_list_url, 'text' : 'Accepted' } );

    accepted_status_list_item.append( ' | ' ).append( accepted_status_list_link );
    $( 'ul.subsubsub' ).append( accepted_status_list_item );

    });
    })(jQuery);
    </script>
    <?php

    } );

    Hope this helps a bit in your implementation :slight_smile:

    Kind regards!

  • mustafa
    • Flash Drive

    Hello and thank you for the support. However, after a discussion we came to the conclusion for having the default appointment flow like payment needs to be done at the time of appointment. I have reverted and added paypal shortcode in appointment page but it doesn’t seem to work like when I click confirm appointment its not showing me the paypal button instead it opens pop up “We have received your appointment” and when I click ok the page reloads and I see pay button with pending status in my appointments. What may be the issue?

  • mustafa
    • Flash Drive

    Yes I did reverted to default settings and everything is working fine and I am able to do payment.

    I just need 1 thing to work this out. When customer books an appointment and does the payment then the status changes to Paid and customer and admin receives confirmation message. This is good.

    Now as service provider/ Admin when I change the status from Paid to Confirmed from backend then I want to send a notification to user with custom subject and body so that user knows that their appointment is finally confirmed. This will make the flow right

    or

    Once the payment is done the status should change to confirmed and not paid like auto confirm so that the above step can be avoided.

    Support granted https://iechusaini-uat.org

  • Panos
    • SLS

    Hey mustafa !

    You could try out this snippet in a mu-plugin:

    add_action( 'wpmudev_appointments_update_appointment_status', function( $app_id, $new_status, $old_status ){

    if ( 'paid' == $new_status && 'pending' == $old_status ) {
    appointments_update_appointment_status( $app_id, 'confirmed' );
    }

    }, 20, 3 );

    This should set the appointment status to confirmed after payment. Give it a try in a staging site and let us know how it goes on your side.

    Kind regards!

  • Panos
    • SLS

    Hi mustafa !

    You’re right! misted that. You can try using the following snippet instead :

    add_action( 'wpmudev_appointments_update_appointment_status', function( $app_id, $new_status, $old_status ){

    if ( 'paid' == $new_status && 'pending' == $old_status ) {
    global $wpdb;
    $table = appointments_get_table( 'appointments' );
    $wpdb->query(
    $wpdb->prepare(
    "UPDATE {$table} SET status = 'confirmed' WHERE ID=%d",
    $app_id
    )
    );
    }

    }, 20, 3 );

    I would strongly recommend to first test out any custom snippet in a test/staging site. For checking emails you can use several plugin (eg https://wordpress.org/plugins/wp-mail-logging/)

    Kind regards!

  • mustafa
    • Flash Drive

    Hello and thank you for your efforts. However, the client didn’t like the idea of making paid as confirmed. Can u check for this solution from my previous request.

    I just need 1 thing to work this out. When customer books an appointment and does the payment then the status changes to Paid and customer and admin receives confirmation message. This is good.

    Now as service provider/ Admin when I change the status from Paid to Confirmed from back end then I want to send a notification to user with custom subject and body so that user knows that their appointment is finally confirmed. This will make the flow right.

  • Panos
    • SLS

    Hey mustafa !

    For that you can try out the appointments_send_confirmation filter for sending a custom confirmation email. Here’s an example :

    add_filter( 'appointments_send_confirmation', function( $send_confirmation, $app_id ) {

    if ( ! isset( $_REQUEST['status'] ) || 'confirmed' != $_REQUEST['status'] ) {
    return $send_confirmation;
    }

    // Email info sent to Customer
    $customer_subject = 'Confirmation of your Appointment';
    $customer_body = '<p>
    Hey there {{CUSTOMER_NAME}}! <br />
    We are pleased to confirm your appointment on {{SITE_NAME}}. Here are the appointment details:<br />
    Requested service: {{SERVICE_NAME}} <br />
    Date and time: {{APPOINTMENT_DATE}}<br />
    {{SERVICE_PROVIDER}} will assist you for this service. <br />
    </p>

    Kind regards, {{SITE_NAME}}
    ';

    // Email info sent to Service Provider
    $provider_subject = 'Confirmation of your Appointment';
    $provider_body = '<p>
    Hey there {{SERVICE_PROVIDER}}! <br />
    A new appointment has been made on {{SITE_NAME}}. Here are the appointment details:<br />
    Requested service: {{SERVICE_NAME}} <br />
    Date and time: {{APPOINTMENT_DATE}}<br />
    {{SERVICE_PROVIDER}} will assist you for this service. <br />
    </p>

    Kind regards, {{SITE_NAME}}
    ';

    $appointments = appointments();
    $app = appointments_get_appointment( $app_id );
    $options = appointments_get_options();
    $customer_email = $app->get_customer_email();
    $admin_email = $appointments->get_admin_email();
    $worker_email = $appointments->get_worker_email( $app->worker );
    $replacements = array(
    '{{CUSTOMER_NAME}}' => $app->name,
    '{{SERVICE_NAME}}' => $appointments->get_service_name( $app->service ),
    '{{SERVICE_PROVIDER}}' => appointments_get_worker_name( $app->worker ),
    '{{SITE_NAME}}' => wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES ),
    '{{APPOINTMENT_DATE}}' => $app->start,
    '{{PRICE}}' => $app->price,
    '{{PHONE}}' => $app->phone,
    '{{NOTE}}' => $app->note,
    '{{ADDRESS}}' => $app->address,
    '{{CITY}}' => $app->city
    );

    $customer_body = str_replace(
    array_keys( $replacements ),
    array_values( $replacements ),
    $customer_body
    );

    $provider_body = str_replace(
    array_keys( $replacements ),
    array_values( $replacements ),
    $provider_body
    );

    $customer_body = $appointments->add_cancel_link( $customer_body, $app_id );

    // Send to Admin
    $admin_result = wp_mail(
    $admin_email,
    $provider_subject,
    $provider_body,
    $appointments->message_headers()
    );

    // Send to Provider
    $provider_result = wp_mail(
    $worker_email,
    $provider_subject,
    $provider_body,
    $appointments->message_headers()
    );

    // Send to Customer
    $provider_result = wp_mail(
    $customer_email,
    $customer_subject,
    $customer_body,
    $appointments->message_headers()
    );
    return false;
    }, 20, 2 );

    You might want to remove the part that sends he email to the admins to, if your admin is the Provider. I would strongly suggest to first test this out in a staging site, using a Mail Logging plugins too, then move it to your production site.

    Hope this helps!

    Kind regards!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.