Last active
April 22, 2024 13:27
-
-
Save andrewlimaza/579e0a6d985c5230b21e40deb5af0448 to your computer and use it in GitHub Desktop.
Remove Billing Fields for Offsite Payment Gateways using the Address For Free Levels Add On. Paid Memberships Pro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* This code snippet will hide billing fields from certain levels when added using the "Capture Name & Address for Free Levels or for Offsite Gateway" | |
* Please adjust the level ID's values of the $levels_to_hide array, for which levels you want to hide billing fields from. | |
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_pmpro_hide_billing_fields_for_levels() { | |
$levels_to_hide = array(1,3,5); //change level ID's you want to hide billing fields from. | |
$level = pmpro_getLevelAtCheckout(); | |
if ( in_array( $level, $levels_to_hide ) ) { | |
remove_action( 'init', 'pmproaffl_init_include_address_fields_at_checkout', 30 ); | |
remove_action( "pmpro_checkout_boxes", "pmproaffl_pmpro_checkout_boxes_require_address" ); | |
remove_action("pmpro_required_billing_fields", "pmproaffl_pmpro_required_billing_fields", 30); | |
remove_action("pmpro_paypalexpress_session_vars", "pmproaffl_pmpro_paypalexpress_session_vars"); | |
remove_action("pmpro_before_send_to_twocheckout", "pmproaffl_pmpro_paypalexpress_session_vars", 10, 2); | |
remove_action( 'pmpro_checkout_before_change_membership_level', 'pmproaffl_pmpro_checkout_before_change_membership_level', 5, 2); | |
remove_action( 'pmpro_checkout_preheader', 'pmproaffl_init_load_session_vars', 5 ); | |
remove_filter( 'pmpro_checkout_order_free', 'pmproaffl_pmpro_checkout_order_free' ); | |
} | |
} | |
add_action( 'init', 'my_pmpro_hide_billing_fields_for_levels' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This recipe is included in the blog post on "Exclude billing fields from some membership levels at checkout." at Paid Memberships Pro here: https://www.paidmembershipspro.com/exclude-billing-fields-from-some-membership-levels-at-checkout/