Skip to content

Commit

Permalink
Merge pull request #251 from geminilabs/hotfix/give_require_billing_a…
Browse files Browse the repository at this point in the history
…ddress

Re: #249
  • Loading branch information
Devin Walker committed Sep 16, 2015
2 parents 7609786 + 2a7dc09 commit 9db2c22
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
5 changes: 2 additions & 3 deletions includes/gateways/offline-donations.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
* @since 1.0
*/


/**
* Register the payment gateway
*
Expand Down Expand Up @@ -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' );
}

Expand Down Expand Up @@ -365,4 +364,4 @@ function give_get_default_offline_donation_email_content() {

return apply_filters( 'give_default_offline_donation_content', $default_text );

}
}
23 changes: 20 additions & 3 deletions includes/process-purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand All @@ -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
*
Expand Down Expand Up @@ -999,4 +1016,4 @@ function give_check_purchase_email( $valid_data, $posted ) {
}
}

add_action( 'give_checkout_error_checks', 'give_check_purchase_email', 10, 2 );
add_action( 'give_checkout_error_checks', 'give_check_purchase_email', 10, 2 );

0 comments on commit 9db2c22

Please sign in to comment.