diff --git a/assets/js/frontend/give-ajax.js b/assets/js/frontend/give-ajax.js index 97d345ee9b..c937bfa0a4 100644 --- a/assets/js/frontend/give-ajax.js +++ b/assets/js/frontend/give-ajax.js @@ -121,12 +121,11 @@ jQuery(document).ready(function ($) { /** * Donation Form AJAX Submission - * + * * @description: Process the donation submit */ $('body').on('click touchend', '#give-purchase-button', function (e) { - //this form object var this_form = $(this).parents('form.give-form'); @@ -139,9 +138,9 @@ jQuery(document).ready(function ($) { //HTML5 required check validity if (typeof give_purchase_form.checkValidity === "function" && give_purchase_form.checkValidity() === false) { - + //Don't leave any hanging loading animations - loading_animation.fadeOut(); + loading_animation.fadeOut(); //Check for Safari (doesn't support HTML5 required) if ((navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1) === false) { @@ -162,6 +161,7 @@ jQuery(document).ready(function ($) { //Submit form via AJAX $.post(give_global_vars.ajaxurl, this_form.serialize() + '&action=give_process_checkout&give_ajax=true', function (data) { + if ($.trim(data) == 'success') { //Remove any errors this_form.find('.give_errors').remove(); @@ -174,6 +174,7 @@ jQuery(document).ready(function ($) { this_form.find('.give_errors').remove(); this_form.find('#give_purchase_submit').before(data); } + }); }); diff --git a/includes/misc-functions.php b/includes/misc-functions.php index 1e4784f3dd..61854e10f0 100644 --- a/includes/misc-functions.php +++ b/includes/misc-functions.php @@ -235,17 +235,17 @@ function give_is_cc_verify_enabled() { /** - * Checks if users can only give when logged in + * Checks if users can only donate when logged in * * @since 1.0 * @global $give_options * @return bool $ret Whether or not the logged_in_only setting is set */ -function give_logged_in_only() { +function give_logged_in_only( $form_id ) { + + $form_option = get_post_meta( $form_id, '_give_logged_in_only', true ); - global $give_options; - - $ret = ! empty( $give_options['logged_in_only'] ); + $ret = ! empty( $form_option ) ? $form_option : false; return (bool) apply_filters( 'give_logged_in_only', $ret );