Send service provider an email when Appointment is "Paid"

Hi again,

Ok, now to try to explain this one! My site allows users to book Appointments (Appointments+ plugin) integrated thru MarketPress. The only payment method i use CubePoints. So at the the moment when an appointment is booked I (the admin) & the client receive an email confirming the booking. These emails are triggered by the MarketPress>Payment>CubePoint Settings tab. Nothing is sent to the service provider, which is what i would like because even though the booking is paid for i don't consider it confirmed until the service provider confirms it. Once the service provider (or the admin) confirms the booking changing the status from 'paid' to 'confirmed' everyone (admin, service provider & client) currently receives another email triggered by the Appointments+>General>Notifications tab. This email i am very happy with.

The problem at the moment is when an appointment is booked & 'paid' the service provider receives nothing, so unless they check their profile regularly or i forward the the email i get from MarketPress>Payment>CubePoint Settings tab then they may miss the appointment.

What i am hoping to do is, as soon a booking is paid for i would love for it to trigger the "An appointment requires your confirmation" email. This email used to be sent to the admin & service provider when an appointment was 'pending', this was when i used to use just the Appointments+ plugin without integrating with MarketPress. It was a simple email, but at least it let the service provider know they had an appointment that required them to confirm. The emails contents were as follows:

Title: An appointment requires your confirmation

Body: The new appointment has an ID 11 and you can confirm it using your profile page.

If i can get this email to be sent even though the appointment is 'paid' that would be great!

Thanks for any advice i can get on this one!

  • Hakan

    Hi,

    First of all I didn't get any tag on this topic until now.

    Secondly, Cubepoints is not a natively supported payment gateway by MarketPress. So we simply don't support it.

    Thirdly there are more than 130 filter and action hooks in A+ and also dozens in MarketPress. I believe one of them may fit to your cause, most likely "app_new_appointment" or "mp_order_paid" filters. I am not sure.

    If it doesn't fit, you should ask Cubepoints addon developer, what action is triggered when a payment is done in Cubepoints. But you see, that is not our software.

    Cheers,
    Hakan

  • joel_english

    Hi Hakan,

    Are you sure Cubepoints isn't a supported payment gateway? If you have Cubepoints installed it becomes a gateway, see my screenshot please. I didn't do any changes to add it, it just appears if you have Cubepoints plugin installed.

    It also has some options below which work also, except for some reason the 'Order Confirmation Email' doesn't get sent to the client..although i wish it would.

    The reason i brought this up is because i'm not much of a coder & was looking for some help in being able to track down the correct .php file & part of the code i would need to change to the allow an email to be sent to the service provider even when the status of the order is PAID & not just PENDING. If it was PENDING the service provider should receive the email i mentioned in my first post which is:

    Title: An appointment requires your confirmation

    Body: The new appointment has an ID ** and you can confirm it using your profile page.

    I would like that email to be sent to the service provider even when the product has been PAID & not just PENDING. Is that possible? And if so, could i get some help finding which hook to amend to make that happen?

    Thanks, Joel

  • joel_english

    Whoops...

    It also has some options below which work also, except for some reason the 'Order Confirmation Email' doesn't get sent to the client..although i wish it would.

    I told a lie here, just tested again & i did receive the 'Order Confirmation Email' from the CubePoints settings page (in screenshot) when i booked an a Appointment..so all good for that part of it.

    Still need to get an email sent to the service provider to get them to check there profile & confirm their own appointments. As the admin i receive an email to alert me of a purchase made thru the MarketPress store but i don't want to have to confirm all appointments because i cant know my service providers ability to go thru with the appointment.

    Thanks

  • Hakan

    Hi,

    You are right that Cubepoints is a payment gateway of MarketPress which is activated when Cubepoints plugin is activated. Since it was hidden, I missed that.

    I am sorry about the misinformation.

    MarketPress is supposed to send the confirmation email, but it is just payment information and it does not include appointment details. Also service provider is not informed about the appointment in this case. I agree that this is a point to be considered.

    If you add these codes in functions.php of your current theme, client, admin, and also service provider will get a detailed confirmation of appointment email after payment completed:

    function app_mp_send_note( $app_id ) {
    global $appointments;
    $appointments->send_confirmation( $app_id );
    }
    add_action( 'app_mp_order_paid', 'app_mp_send_note' );

    Appointments+ confirmation email settings will be effective for the subject and message text there.

    In a recent release we can add this as standard, but I think this will solve your requirement for now.

    Cheers,
    Hakan

  • joel_english

    Thanks for the help Hakan,

    That code did the trick! I just changed it so it would send the notification email instead of the confirmation email, this way the client will only get the confirmation email when the service provider confirms the appointment. My clients still receive an email from the CubePoints payment gateway settings, so all is good! :slight_smile:

    My code for anyone that wants what i did.

    function app_mp_send_note( $app_id ) {
    global $appointments;
    $appointments->send_notification( $app_id );
    }
    add_action( 'app_mp_order_paid', 'app_mp_send_note' );

    Hakan, it would be great if you could add this to a future update, i recommend getting it to send the service provider the send_notification like i have done. But it would also be great if there was a setting in the plugin to allow for a custom email to be sent to the service provider. I have currently made one by amending the appointments.php.

    The default email says "The new appointment has an ID %s and you can confirm it using your profile page." which tells the service provider the ID, but i don't think the service providers can see the ID number in their profiles, so it would be great to have a short-code which is replaced by the appointments date & time in the email that is sent. That way the service provider knows the date & time for the appointment before they even view their profile. Not sure it's possible, but just some food for thought

    Thanks again for the great plugin & for helping with the code!

    Joel

    `

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.