Skip to content

Commit

Permalink
Merge branch 'dparker1005-stop-filtering-gateway-option' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
ideadude committed Aug 30, 2023
2 parents 1607d99 + 72c676a commit d61496e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
2 changes: 1 addition & 1 deletion js/pmpro-pay-by-check.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function pmpropbc_isLevelFree() {
}

function pmpropbc_isCheckGatewayChosen() {
if(jQuery('input[name=gateway]:checked').val() === 'check') {
if(jQuery('input[name=gateway]:checked').val() === 'check' || pmpropbc.check_only === '1') {
return true;
} else {
return false;
Expand Down
28 changes: 23 additions & 5 deletions pmpro-pay-by-check.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,9 @@ function pmpropbc_checkout_boxes()
</div> <!-- end pmpro_checkout-fields -->
</div> <!-- end #pmpro_payment_method -->
<?php
} elseif ( $gateway_setting != "check" && $options['setting'] == 2 ) { ?>
<input type="hidden" name="gateway" value="check" />
<?php
}
}
add_action("pmpro_checkout_boxes", "pmpropbc_checkout_boxes", 20);
Expand Down Expand Up @@ -235,6 +238,15 @@ function pmpropbc_enqueue_scripts() {
//get original checkout level and another with discount code applied
$pmpro_nocode_level = pmpro_getLevelAtCheckout(false, '^*NOTAREALCODE*^');
$pmpro_code_level = pmpro_getLevelAtCheckout(); //NOTE: could be same as $pmpro_nocode_level if no code was used

// Determine whether this level is a "check only" level.
$check_only = 0;
if ( ! empty( $pmpro_code_level->id ) ) {
$options = pmpropbc_getOptions( $pmpro_code_level->id );
if ( $options['setting'] == 2 ) {
$check_only = 1;
}
}

//restore these values
$pmpro_msg = $omsg;
Expand All @@ -247,6 +259,7 @@ function pmpropbc_enqueue_scripts() {
'pmpro_review' => (bool)$pmpro_review,
'is_admin' => is_admin(),
'hide_billing_address_fields' => apply_filters('pmpro_hide_billing_address_fields', false ),
'check_only' => $check_only,
)
);

Expand Down Expand Up @@ -274,11 +287,15 @@ function pmpropbc_pmpro_valid_gateways($gateways)
}
add_filter("pmpro_valid_gateways", "pmpropbc_pmpro_valid_gateways");

/*
Force check gateway if pbc_setting is 2
*/
/**
* Force check gateway if pbc_setting is 2.
*
* @deprecated TBD Now handled similarly to pbc_setting 1.
*/
function pmpropbc_pmpro_get_gateway($gateway)
{
_deprecated_function( __FUNCTION__, 'TBD' );

$level = pmpro_getLevelAtCheckout();

if ( ! empty( $level->id ) )
Expand All @@ -291,8 +308,6 @@ function pmpropbc_pmpro_get_gateway($gateway)

return $gateway;
}
add_filter('pmpro_get_gateway', 'pmpropbc_pmpro_get_gateway');
add_filter('option_pmpro_gateway', 'pmpropbc_pmpro_get_gateway');

/*
Need to remove some filters added by the check gateway.
Expand All @@ -316,6 +331,9 @@ function pmpropbc_init_include_billing_address_fields()
add_filter('pmpro_include_billing_address_fields', '__return_false', 20);
add_filter('pmpro_include_payment_information_fields', '__return_false', 20);

// Need to also specifically remove them for Stripe.
remove_filter( 'pmpro_include_payment_information_fields', array( 'PMProGateway_stripe', 'pmpro_include_payment_information_fields' ) );

//Hide the toggle section if the PayPal Express Add On is active
remove_action( "pmpro_checkout_boxes", "pmproappe_pmpro_checkout_boxes", 20 );
} else {
Expand Down

0 comments on commit d61496e

Please sign in to comment.