• Resolved Gerdski

    (@gerdski)


    Hello,

    we have a site where you reach the booking form with a link like
    mysite.com/bookingform?product=67
    because someone is interested in Product 67 (for example).

    Now I’d like to access this variable and place it in the phone or the details element of your booking form. I can get the variable with PHP and a shortcode function and extract the name from it (product_id 67 >= product name ‘MYPRODUCT’).

    How can I auto-fill the phone or details element with a text like “I am interested in MYPRODUCT”?

    I have looked at https://wpbookingcalendar.com/faq/, some solutions there are very close…but not for my problem :-/. Maybe you can help me.

    Thanks a lot!

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author wpdevelop

    (@wpdevelop)

    Hello.
    You can check this faq article https://wpbookingcalendar.com/faq/booking-calendar-api/ about where you can find helpful functions.
    You can use the hook for detection of adding new bookings, and then Use your own php function for adding additional info into the booking.
    Kind Regards.

    Thread Starter Gerdski

    (@gerdski)

    Thank you.

    Unfortunately, there is nothing in the FAQ article you mentioned.
    I already used my own function, but it doesn’t work.
    Can you help me?

    Thanks!

    Plugin Author wpdevelop

    (@wpdevelop)

    You can use something similar to this:

    
    /**
     * Hook action after creation  new booking
     * @param int $booking_id
     * @param int $resource_id
     * @param string $str_dates__dd_mm_yyyy    - "30.02.2014, 31.02.2014, 01.03.2014"
     * @param array  $times_array              - array($start_time, $end_time )
     * @param string $booking_form
    function your_cust_func_add_new_booking( $booking_id, $resource_id, $str_dates__dd_mm_yyyy, $times_array , $booking_form  ) {
    
    }
    add_action( 'wpdev_new_booking', 'your_cust_func_add_new_booking', 100, 5 );
    
    Thread Starter Gerdski

    (@gerdski)

    Thanks for your answer.
    But it seems to be an answer for a different question.
    I don’t need to do something after booking but add an URL Parameter to a field before sending off the mail.

    Plugin Author wpdevelop

    (@wpdevelop)

    If you need to add into the field some data just from the URL parameter, so you will need to use your JavaScript code for this. In this case, it’s not about the PHP.
    In Booking Calendar exist only one hook about the saving booking, that I was explained in my previous email.
    Kind Regards.

    Thread Starter Gerdski

    (@gerdski)

    OK, so there seems to be no way to add this Variable but with JavaScript. There is a small bit of PHP needed: $_GET[‘myparameter’], and to write 2 PHP functions to functions.php…

    Plugin Author wpdevelop

    (@wpdevelop)

    Hello.
    Sorry in such way it’s does not exist any hooks.

    But you can check this function:
    function get__client_side_booking_content($my_boook_type = 1 , $my_booking_form = 'standard', $my_selected_dates_without_calendar = '', $cal_count = 1, $bk_otions = array() ) {
    inside of this file: ../wp-content/plugins/booking/core/lib/wpdev-booking-class.php

    You can check there how is insrted data from the user profile for looged in users. For example for second name code looking like this:

    
                                                    // Second Name
                                                    bk_af_reg = /^([A-Za-z0-9_\-\.])*(last|second){1}([_\-\.])?name([A-Za-z0-9_\-\.])*$/;
                                                    if(bk_af_reg.test(bk_af_element.name) != false)
                                                        if (bk_af_element.value == "" )
                                                            bk_af_element.value  = "'.str_replace("'",'',$curr_user->last_name).'";
    

    You can add your code in similar way. But it’s JavaScript.

    Disclaimer! Unfortunately we can not start, right now, some personal customization or custom development, because we have almost no free time.
    Check more about, what support we are providing here https://wpbookingcalendar.com/faq/what-support-do-you-provide/
    Thank you for understanding.
    Please note, if you modify the source code of the Booking Calendar, we will not guarantee the correct work of the plugin and do not support it.
    Kind Regards.

    Thread Starter Gerdski

    (@gerdski)

    I have to use the wp_footer hook for my function:

    <script type=”text/javascript”>
    document.getElementById(“phone1”).value = “‘.$_GET[‘myparameter’].'”;
    </script>’;

    because the form appears to be created very late.

    No need for me to modify your source code, no need for you to customize anything.

    Problem is solved.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘How to use url parameter?’ is closed to new replies.