Created
June 29, 2022 15:06
-
-
Save ipokkel/691c51200f18faa8fb9c66ae37cd90e2 to your computer and use it in GitHub Desktop.
Remove payment plans from an Addon Package checkout.
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 recipe removes payment plans from the PMPro checkout page if | |
* checkout is for an Addon Package. | |
* | |
* You can add this recipe to your site by creating a custom plugin | |
* or using the Code Snippets plugin available for free in the WordPress repository. | |
* Read this companion article for step-by-step directions on either method. | |
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function remove_payment_plans_for_addon_package() { | |
global $pmpro_pages, $post; | |
// Is payment plans and addon packages active? | |
if ( ! function_exists( 'pmpropp_get_plan' ) || ! function_exists( 'pmproap_hasAccess')) { | |
return; | |
} | |
// Are we on checkout for an Addon Package? | |
if ( isset( $_REQUEST['ap'] ) && ! empty( $_REQUEST['ap'] ) && ( is_page( $pmpro_pages['checkout'] ) || strpos( $post->post_content, '[pmpro_checkout' ) !== false ) ) { | |
?> | |
<script type="text/javascript"> | |
jQuery(document).ready(function () { | |
jQuery("#pmpropp_select_payment_plan").remove(); | |
}); | |
</script> | |
<?php | |
} | |
} | |
add_action( 'wp_footer', 'remove_payment_plans_for_addon_package' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment