Skip to content

Commit

Permalink
Merge pull request #128 from dparker1005/wait_to_get_level_at_checkout
Browse files Browse the repository at this point in the history
Delay calling pmpro_getLevelAtCheckout() until the checkout level is retrieved
  • Loading branch information
dparker1005 authored Sep 25, 2024
2 parents 57c2f7f + 8f072f7 commit a971f86
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions includes/checkout.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,16 @@ function pmpropbc_enqueue_scripts() {
Need to remove some filters added by the check gateway.
The default gateway will have it's own idea RE this.
*/
function pmpropbc_init_include_billing_address_fields()
{
function pmpropbc_init_include_billing_address_fields( $level = null) {
//make sure PMPro is active
if(!function_exists('pmpro_getGateway'))
return;

//billing address and payment info fields
$level = pmpro_getLevelAtCheckout();
if ( empty( $level ) ) {
$level = pmpro_getLevelAtCheckout();
}

if ( ! empty( $level->id ) )
{
$options = pmpropbc_getOptions( $level->id );
Expand Down Expand Up @@ -227,7 +229,7 @@ function pmpropbc_init_include_billing_address_fields()
remove_filter('pmpro_checkout_after_payment_information_fields', array('PMProGateway_check', 'pmpro_checkout_after_payment_information_fields'));
add_filter('pmpro_checkout_after_payment_information_fields', 'pmpropbc_pmpro_checkout_after_payment_information_fields');
}
add_action('init', 'pmpropbc_init_include_billing_address_fields', 20);
add_action( 'pmpro_checkout_preheader_after_get_level_at_checkout', 'pmpropbc_init_include_billing_address_fields', 20, 1 );

/**
* Cancels all previously pending check orders if a user purchases the same level via a different payment method.
Expand Down

0 comments on commit a971f86

Please sign in to comment.