WordPress.org

Ready to get started?Download WordPress

Forums

Events Manager
[resolved] Add Terms and Conditions to reservation form? (16 posts)

  1. wzshop
    Member
    Posted 1 year ago #

    Hello,
    Thanks a lot for this great plugin. I was wondering though if it would be possible to add a checkbox for people to check / agree with the Terms and Conditions, when they want to make a reservation. Of course this checkbox needs to be checked in order to sent the reservation form.

    Any possibilities to accomplish the above?
    Thanks again, Robbert

    http://wordpress.org/extend/plugins/events-manager/

  2. caimin_nwl
    NetWebLogic Support
    Posted 1 year ago #

    Hi Robert,

    If you have the Pro version this can done with the Forms Editor. Otherwise, you'd need to copy and modify the booking-fields.php template at /plugins/events-manager/templates/forms/bookingform.

    See here for instructions on using templates:
    http://wp-events-plugin.com/documentation/using-template-files/

    One way of doing it would be to use something like jQuery to hide the fields in the booking form unless the user has selected a checkbox.

  3. wzshop
    Member
    Posted 1 year ago #

    Thanks a lot. That will work!

  4. wzshop
    Member
    Posted 1 year ago #

    Ok well, i managed to add a simple checkbox. Is there any way to validate if the checkbox is checked and display an error message when it is not checked?

    Do i need to customly add this validation in a js file?

    Any help would be greatly appreciated!

  5. Philip John
    Member
    Posted 1 year ago #

    Hiya!

    You could do that using jQuery... take a look at adding scripts at http://codex.wordpress.org/Function_Reference/wp_enqueue_script

    Cheers,
    Phil

  6. wzshop
    Member
    Posted 1 year ago #

    Ok thanks,
    Here is what ive done.

    In functions.php i added the code to load a custom js file:

    <?php
    function my_scripts_method() {
    wp_enqueue_script(
    		'custom-script',
    		get_template_directory_uri() . '/js/custom_script.js',
    		array( 'jquery' )
    	);
    }
    
    add_action( 'wp_enqueue_scripts', 'my_scripts_method' );
    ?>

    This works and actually loads the js file in my theme.
    Then in my theme folder i uploaded the custom_script.js file with the code:

    $(document).on('submit', '.em-booking-form', function(e){
    	if($("#booking_terms").prop('checked') == false){
        //do something
    	  alert("is not checked");
    });

    However the alert is not displayed when i try to submit the booking form and uncheck the checkbox. But when i add the above code (of my custom js file) in the file events-manager/includes/js/bookingsform.js the check/alert is working (so i guess the custom script is not called by the bookings form?). However i don't want to edit that file because the custom coding will get overwritten when i do an update of the plugin.

    So why is the check only working when added in the bookingsform.js file? And is there a way to validate the checkbox through jquery, by a custom made js file? Maybe by using an action hook?

    Thanks again!

  7. caimin_nwl
    NetWebLogic Support
    Posted 1 year ago #

    I think the missing part is that you're not wrapping your custom javascript in a document ready function. If you do that it should work.

  8. wzshop
    Member
    Posted 1 year ago #

    Hmm, i try to duplicate the on.submit function. Im pretty new with jquery. Can you please tell me what i exactly need to change to make it work?

    Thanks.

  9. caimin_nwl
    NetWebLogic Support
    Posted 1 year ago #

    You need to enclose your code in something like this:

    ( document ).ready(function() {
    
    // your code goes here
    
    });

    This should add your code to the submit button after it's loaded. At the moment, I think your code isn't working because the submit button isn't ready at the point you're trying to add the code for it.

    This might help:
    http://learn.jquery.com/using-jquery-core/document-ready/

  10. wzshop
    Member
    Posted 1 year ago #

    Hey,
    Thanks for your reply!

    I tried this:

    ( document ).ready(function() {
    
    // your code goes here
    $(document).on('submit', '.em-booking-form', function(e){
    	if($("#booking_terms").prop('checked') == false){
        //do something
    	  alert("is not checked");
    });
    });

    And/Or

    // your code goes here
    $(document).ready('submit', '.em-booking-form', function(e){
    	if($("#booking_terms").prop('checked') == false){
        //do something
    	  alert("is not checked");
    });

    But both did nothing... Am i doing something wrong?
    Thanks again!

  11. caimin_nwl
    NetWebLogic Support
    Posted 1 year ago #

    Sorry, the first character of my example got cut off. Here the correct version, with your code in it.

    I've also added an alert right at the start. If that doesn't pop up when your page loads, you know the ready function is in the wrong place or isn't being loaded for some reason.

    If the alert appears but your code doesn't work, you know there's a problem with your code.

    $( document ).ready(function() {
    alert("Ready function called");
    $(document).on('submit', '.em-booking-form', function(e){
    	if($("#booking_terms").prop('checked') == false){
        //do something
    	  alert("is not checked");
    });
    
    });
  12. wzshop
    Member
    Posted 1 year ago #

    Ah, thanks a lot. This helps me to further debug this issue:).
    No alert is being shown, so i guess that the function is not being loaded, as i already suspected. However the custom js file is added in the source header, by the wp_enqueue_script.

    Any possibility for the form to load the custom js file?

    Any ideas?
    Thanks again!

  13. angelo
    NetWebLogic Support
    Posted 1 year ago #

  14. wzshop
    Member
    Posted 1 year ago #

    thanks, but the script is loaded. however the js is not called when the form is submitted...
    Any ideas?

    Thanks.

  15. wzshop
    Member
    Posted 1 year ago #

    still not working..

  16. wzshop
    Member
    Posted 1 year ago #

    fixed it.
    used the do_action('em_gateway_js'); hook in classes/em-bookings.php file
    thanks all

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic