Okay
  Public Ticket #1882789
Add custom code after booking
Closed

Comments

  •  2
    olderdais started the conversation

    Hello,

    I want to know how can I add some custom code after each booking. I´m using a personal database to store more information for the appointments pointing to the Amelia databases and just need to add a new row on my table once the booking was done, how can I do it? Any hook I can add'

    Thank you.

    Angel.

  • [deleted] replied

    Hi Angel,

    Thank you for your inquiry.

    We don't provide WP hooks in our plugin, only JS callback method (with appointment data as parameter), that will be executed (if method is defined) after successful booking.

    This method can  be added over page editor, e.g.:

    <script>
    window.beforeAddToCalendarLoaded = function (data) {
     // your code goes here
    }
    </script>

    Best regards.

  •  2
    olderdais replied

    Hi Isidora,

    So in the page I have the shortcode [ameliabooking] I can add the code you just sent me?

    All that I need from the amelia database "wp_amelia_appointments" is the id field of the appointment.

    Regards.


  • [deleted] replied

    Hi Angel,

    You will place the code on that page, just in the text area. Please see the picture below for this:4033061835.png


    Callback method will return parameter data with fields: data.responseData.booking.appointmentId AND, data.responseData.booking.id that you could use.

    9258631732.png


    Method will be executed after booking so you can get appointment ID from parameter data.

    Best regards.

  •  2
    olderdais replied

    Hi Isidora,

    So I guess is not possible to run a SQL query on that function to populate my table with some of that amelia table info, right?

    Thanks.

    Angel.

  • [deleted] replied

    Hi Andel,

    No, unfortunately you can't. The only way would be to use some existing, or write new endpoint, and to send the data with ajax call.

    Best regards.

  •  2
    olderdais replied

    Hi Isidora, 

    Ok, thank you for your response.

    Regards.

    Angel.

  • [deleted] replied

    Hi Angel,

    You are welcome. 

    Best regards.