diff --git a/includes/gateways/offline-donations.php b/includes/gateways/offline-donations.php index 862d7a1e4d..8dccd19fdd 100644 --- a/includes/gateways/offline-donations.php +++ b/includes/gateways/offline-donations.php @@ -9,7 +9,6 @@ * @since 1.0 */ - /** * Register the payment gateway * @@ -70,7 +69,7 @@ function give_offline_payment_cc_form( $form_id ) { $post_offline_cc_fields = get_post_meta( $form_id, '_give_offline_donation_enable_billing_fields_single', true ); $global_offline_cc_fields = give_get_option( 'give_offline_donation_enable_billing_fields' ); - if ( $global_offline_cc_fields == 'on' || $post_offline_cc_fields == 'on' ) { + if ( $global_offline_cc_fields == 'on' || ( $post_offline_customization_option == 'yes' && $post_offline_cc_fields == 'on' ) ) { add_action( 'give_before_offline_info_fields', 'give_default_cc_address_fields' ); } @@ -365,4 +364,4 @@ function give_get_default_offline_donation_email_content() { return apply_filters( 'give_default_offline_donation_content', $default_text ); -} \ No newline at end of file +} diff --git a/includes/process-purchase.php b/includes/process-purchase.php index 5b4419a908..10fce887de 100644 --- a/includes/process-purchase.php +++ b/includes/process-purchase.php @@ -6,7 +6,7 @@ * @subpackage Functions * @copyright Copyright (c) 2015, WordImpress * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License - * @since 1.0 + * @since 1.0.1 */ // Exit if accessed directly @@ -278,7 +278,7 @@ function give_purchase_form_required_fields() { ); // Let payment gateways and other extensions determine if address fields should be required - $require_address = apply_filters( 'give_require_billing_address', true ); + $require_address = give_require_billing_address(); if ( $require_address ) { $required_fields['card_zip'] = array( @@ -303,6 +303,23 @@ function give_purchase_form_required_fields() { } +/** + * Check if the Billing Address is required + * + * @since 1.0.1 + * @return bool + */ +function give_require_billing_address() { + + $return = false; + + if ( isset( $_POST['billing_country'] ) ) { + $return = true; + } + + return apply_filters( 'give_require_billing_address', $return ); +} + /** * Purchase Form Validate Logged In User * @@ -999,4 +1016,4 @@ function give_check_purchase_email( $valid_data, $posted ) { } } -add_action( 'give_checkout_error_checks', 'give_check_purchase_email', 10, 2 ); \ No newline at end of file +add_action( 'give_checkout_error_checks', 'give_check_purchase_email', 10, 2 );